Cannot end my loop properly

Thread Solved

Join Date: Jun 2009
Posts: 1
Reputation: keygrl2001 is an unknown quantity at this point 
Solved Threads: 0
keygrl2001 keygrl2001 is offline Offline
Newbie Poster

Cannot end my loop properly

 
0
  #1
Jun 11th, 2009
I am writing a program in which the user enters a number between 1 and 3 (3 meaning that he/she would like to quit) and I am using a switch function within a do-while loop. I am trying to get the program to end the loop when the user enters the number 3. However, my program is only continuing the loop when the user enters 3. Can anyone help me fix this please? Thanks so much!

-Mikaela
Attached Files
File Type: cpp Exam01.cpp (1.5 KB, 3 views)
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 50
Reputation: sloan31 is an unknown quantity at this point 
Solved Threads: 3
sloan31 sloan31 is offline Offline
Junior Poster in Training

Re: Cannot end my loop properly

 
0
  #2
Jun 15th, 2009
Follow the logic flow line by line, you are asking for the user to enter the price for the item after they make the choice between 1,2, or 3 regardless of which choice they made.

The do...while loop involving the switch statement doesn't come into play until after the user has entered a price. So unless they enter a price of 3, this will never exit.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC