943,677 Members | Top Members by Rank

Ad:
Jun 11th, 2009
0

Cannot end my loop properly

Expand Post »
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, 12 views)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
keygrl2001 is offline Offline
1 posts
since Jun 2009
Jun 15th, 2009
0

Re: Cannot end my loop properly

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.
Reputation Points: 14
Solved Threads: 3
Junior Poster in Training
sloan31 is offline Offline
65 posts
since Apr 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

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 IT Professionals' Lounge Forum Timeline: Please help me decide - MSc Computing, where and why
Next Thread in IT Professionals' Lounge Forum Timeline: Decompiler





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


Follow us on Twitter


© 2011 DaniWeb® LLC