program design
program design
program design
program design
program design
program design program design program design program design program design program design program design program design
program design program design
program design
Go Back  Xtreme Visual Basic Talk > > > program design


Reply
 
Thread Tools Display Modes
  #1  
Old 01-25-2014, 03:37 PM
junied32167 junied32167 is offline
Newcomer
 
Join Date: Jan 2014
Posts: 3
Default program design


I need help with the finishing of my program.
I need to know how to loop an if statement like the following.
dim mynum as integer
if my num > 50
console.writeline ("please enter a number below 50)"
else if mynum < 10 console.writeline("please enter a number above 10")
end if
How do i loop this until the conditions are met to
Reply With Quote
  #2  
Old 01-25-2014, 07:54 PM
passel's Avatar
passelprogram design passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,026
Default

Well, first need to put a loop around it of course.
You don't show where the input comes in, but that would have to be in the loop, at the top.
The type of loop needs to be one that will execute at least once, or have the test condition initialized so that you go into the loop initially, to get the input.
So, there are any number of choices, but the obvious first two are, using the Do ... Loop While condition, or preset the condition and use Do While Condition .... Loop

Code:
'Preset condition example
Dim mynum as Integer = -1  'preset it to invalid

Do While mynum = -1
  mynum = 'however you want to get your input
  If mynum > 50 Then
    mynum = -1    'flag that it is invalid
  ElseIf mynum < 10 Then
    mynum = -1
  End If

  If mynum = -1 Then 
    Console.WriteLine ("Please enter a number in the range of 10 to 50")
  End If
Loop
'your code get's here once the number is (10 or greater) and (50 or less)
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #3  
Old 02-02-2014, 06:46 AM
junied32167 junied32167 is offline
Newcomer
 
Join Date: Jan 2014
Posts: 3
Default

I have almost finished my program but need help with the followI have almost finished making the program but I am stuck with making the bill.
My program allows the user to select from a paintype by making a choice from 1-3. 1 for luxury which is£1.75 another for standard which is £1.00 and the third choice economy which is 0.40p but for the bill I have to times the price of the paint by the area of the room.
I have tried doing this
view sourceprint?
1
Dim paintprice As Double
2
paintprice = paintType * areaofroom
3
Console.WriteLine(paintType * areaofroom)
4
Console.WriteLine(" You are a winner")
5
Console.ReadLine()
Reply With Quote
  #4  
Old 02-06-2014, 08:59 AM
CharlieMay's Avatar
CharlieMay CharlieMay is offline
Regular
 
Join Date: Sep 2009
Location: Indiana
Posts: 89
Default

Can you clarify what is not working?

You are calculating a paintprice = paintType * areaofroom

which means your next line could just be
Console.WriteLine(paintprice.ToString)

no reason to perform the calculation inside the WriteLine method just use the variable that holds that result.

Other than that, a little more explanation of what is happening in your code when you get to this point would be helpful in answering any question you might have.
__________________
I thought I knew what I was doing...
...And then I turned on Option Strict
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
program design
program design
program design program design
program design
program design
program design program design program design program design program design program design program design
program design
program design
 
program design
program design
 
-->