943,722 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 795
  • VB.NET RSS
Jul 22nd, 2008
0

Is this correct

Expand Post »
Write the pseudocode for a program that uses a single while loop to print the numbers from 20 to 25 and from 40 to 45. your loop will have at least one nested "if" statement that will determine when the numbers should be printed.


VB.NET Syntax (Toggle Plain Text)
  1. If X >= 20 Then
  2. If X <= 25 Then Print X
  3. End If
  4. If X>=40 Then
  5. If X <=45 Then Print X
  6. End If
Last edited by Tekmaven; Jul 22nd, 2008 at 7:39 pm. Reason: Code tags
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
army88m2 is offline Offline
21 posts
since Jul 2008
Jul 22nd, 2008
0

Re: Is this correct

Hi,
Your code is doing well.
Just in case, I have added the while loop in yours:
VBNET Syntax (Toggle Plain Text)
  1. Dim x As Integer
  2. Do While x <= 45
  3. If x >= 20 Then
  4. If x <= 25 Then Debug.Print(x)
  5. End If
  6. If x >= 40 Then
  7. If x <= 45 Then Debug.Print(x)
  8. End If
  9. x = x + 1
  10. Loop

Or, you can do this:
VBNET Syntax (Toggle Plain Text)
  1. Dim x As Integer = 20
  2. Do While x <= 45
  3. If (x >= 20 And x <= 25) Or (x >= 40 And x <= 45) Then
  4. Debug.Print(x)
  5. End If
  6. x = x + 1
  7. Loop
Reputation Points: 18
Solved Threads: 7
Junior Poster in Training
dmf1978 is offline Offline
51 posts
since Aug 2006
Jul 22nd, 2008
0

Re: Is this correct

So here's the question. I need to write the pseudocode for a program that uses a single while...loop to print the numbers from 20 to 25 and from 40 to 45. Your loop will have at least one nested "if" statement that will determine when the numbers should be printed.

Here's what I came up with.

VB.NET Syntax (Toggle Plain Text)
  1. If X > = 20 Then
  2. If X < = 25 Then Print X
  3. End If
  4. If X > =40 Then
  5. If X < =45 Then Print X
  6. End If
Last edited by Tekmaven; Jul 22nd, 2008 at 7:42 pm. Reason: Code tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
army88m2 is offline Offline
21 posts
since Jul 2008
Jul 22nd, 2008
0

Re: Is this correct

Well...
That is what I've answered...
Your code have *at least* one nested "If". Actually, yours has four "If" statements.

If you need the pseudo-code, you can write:
VB.NET Syntax (Toggle Plain Text)
  1. X = 0
  2. WHILE X <= 45
  3. IF (X >= 20 AND X <= 25) OR (X >= 40 AND X <= 45)
  4. PRINT X
  5. END IF
  6. X = X + 1
  7. END WHILE
which, isn't too much different from the actual VB.Net code...
Last edited by dmf1978; Jul 22nd, 2008 at 7:38 pm.
Reputation Points: 18
Solved Threads: 7
Junior Poster in Training
dmf1978 is offline Offline
51 posts
since Aug 2006
Jul 24th, 2008
0

Re: Is this correct

Hi,
Is your problem solved?
Reputation Points: 18
Solved Threads: 7
Junior Poster in Training
dmf1978 is offline Offline
51 posts
since Aug 2006
Jul 24th, 2008
0

Re: Is this correct

Yes it is thank you for all your help on this.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
army88m2 is offline Offline
21 posts
since Jul 2008
Jul 24th, 2008
0

Re: Is this correct

Hey I was wondering if this is correct or not. I need to read each record from the inventory database. Print a price tag for each item in inventory. Count & print the total number of tags printed. Sum and print the total retail value of the inventory in the store.




Read the first record
While not eof
Print fldItemnumber , fldDescription , fldQuantityonhand , fldRetailPrice
ItemCount = ItemCount +1
Totalretailvalue = (fldQuantity * fldRetailprice )
Read next record
Loop
Print “Retail price : “ & ItemCount
Print “Value of Inventory = “ & Totalretaivalue
Reputation Points: 10
Solved Threads: 0
Newbie Poster
army88m2 is offline Offline
21 posts
since Jul 2008
Jul 24th, 2008
0

Re: Is this correct

Hi,
Then, mark this thread solved.
Reputation Points: 18
Solved Threads: 7
Junior Poster in Training
dmf1978 is offline Offline
51 posts
since Aug 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Delete From String array
Next Thread in VB.NET Forum Timeline: Code





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC