Is this correct

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2008
Posts: 21
Reputation: army88m2 is an unknown quantity at this point 
Solved Threads: 0
army88m2 army88m2 is offline Offline
Newbie Poster

Is this correct

 
0
  #1
Jul 22nd, 2008
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.


  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
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 51
Reputation: dmf1978 is an unknown quantity at this point 
Solved Threads: 7
dmf1978's Avatar
dmf1978 dmf1978 is offline Offline
Junior Poster in Training

Re: Is this correct

 
0
  #2
Jul 22nd, 2008
Hi,
Your code is doing well.
Just in case, I have added the while loop in yours:
  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:
  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
-- Martín
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 21
Reputation: army88m2 is an unknown quantity at this point 
Solved Threads: 0
army88m2 army88m2 is offline Offline
Newbie Poster

Re: Is this correct

 
0
  #3
Jul 22nd, 2008
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.

  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
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 51
Reputation: dmf1978 is an unknown quantity at this point 
Solved Threads: 7
dmf1978's Avatar
dmf1978 dmf1978 is offline Offline
Junior Poster in Training

Re: Is this correct

 
0
  #4
Jul 22nd, 2008
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:
  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.
-- Martín
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 51
Reputation: dmf1978 is an unknown quantity at this point 
Solved Threads: 7
dmf1978's Avatar
dmf1978 dmf1978 is offline Offline
Junior Poster in Training

Re: Is this correct

 
0
  #5
Jul 24th, 2008
Hi,
Is your problem solved?
-- Martín
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 21
Reputation: army88m2 is an unknown quantity at this point 
Solved Threads: 0
army88m2 army88m2 is offline Offline
Newbie Poster

Re: Is this correct

 
0
  #6
Jul 24th, 2008
Yes it is thank you for all your help on this.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 21
Reputation: army88m2 is an unknown quantity at this point 
Solved Threads: 0
army88m2 army88m2 is offline Offline
Newbie Poster

Re: Is this correct

 
0
  #7
Jul 24th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 51
Reputation: dmf1978 is an unknown quantity at this point 
Solved Threads: 7
dmf1978's Avatar
dmf1978 dmf1978 is offline Offline
Junior Poster in Training

Re: Is this correct

 
0
  #8
Jul 24th, 2008
Hi,
Then, mark this thread solved.
-- Martín
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC