Error Checking Loop
1 New Topic/Question Reply 5 Replies - 6318 Views - Last Post: 27 October 2009 - 11:40 AM Rate Topic: #1 winggundam3451 New D.I.C Head Reputation: 0 Posts: 15 Joined: 03-October 09 Error checking user input with loop Posted 26 October 2009 - 09:35 PM I would post the entire code.. but this a popular hw assignment and I'm not giving it out. This function: void getbet (int money, int &bet ) { cout << "Lets play HiLo! Enter a bet!--->"; cin >> bet; while ( (bet > money) || (bet < 0) ) { cout << "Enter a valid bet please--->"; cin >> bet; } } Reads in a bet from the user playing a HighLow number guessing game. Part of the problem is to have it check for invalid inputs. I have it making sure you cannot bet 0 dollars and you cannot bet more than you have. I have to guard against letters and any input which would be an invalid bet. Ive included cctype at the top of my code to allow me to use isalpha and similar cctypes. However, they do not check. It just throws it into an endless loop. Any suggestions ? Thanks, Ryan Is This A Good Question/Topic? 0 Back to top MultiQuote Quote + Reply Replies To: Error checking user input with loop #2 OliveOyl3471 Everybody's crazy but me! Reputation: 135 Posts: 6,581 Joined: 11-July 07 Re: Error checking user input with loop Posted 26 October 2009 - 10:33 PM void getbet (int money, int &bet ) { cout << "Lets play HiLo! Enter a bet!--->"; cin >> bet; while (!cin.good()) //checks to see if the input is not good { cout <<"You must type a number.\n"; cin.clear();//clear the error state cin.ignore(numeric_limits
Inappropriate Virus/Danger Broken Links Other Back to search results How can I get out of the infinite Loop of Error Checking in TurboTax Premier? I'm trying to file an amended return. I get to the Review section, and it tells me that it found some errors on the return. Initially I had to select the reason for the amendment. I did that, saved and clicked next. Then it tells me that they recommend running error check again. So I run error check again. Again, it comes back and says "We found some errors on one of your tax returns. Let's fix them now." I click http://www.dreamincode.net/forums/topic/134639-error-checking-user-input-with-loop/ the FIX ERRORS button and it goes back to the screen that says "Run Error Check Again - If you have fixed errors or made any changes to your return, we recommend that you run Error Check again. Otherwise, select Done. It keeps looping through the "Run Error Check Again" screen and the "Error Check - Fix Errors" screen. What can I do? I'm using the CD version on My Mac. TurboTax_InfiniteLoop_mbs.png https://ttlc.intuit.com/questions/2260922-how-can-i-get-out-of-the-infinite-loop-of-error-checking-in-turbotax-premier Comment Asked by mbsspike TurboTax Premier Options Edit Ask for details Archive hide info × Close Why do you want to report this? Spam Profanity Threats/Abuse Inappropriate Virus/Danger Broken Links Other Answer Hello mbsspike**** If Turbotax was installed from a DVD, make sure the disc is ejected*****Deleting your Preferences list (also called a plist) can help you resolve issues related to TurboTax for the Macintosh, including program crashes and problems downloading states and/or updates. Quit TurboTax. Then, use one of the following methods: Method 1 Click anywhere on your empty desktop and then make sure Finder is in your menu bar (top left, next to the apple icon). From the Go menu, select Home. Click the Library folder and then click the Preferences folder. Note: This folder may be hidden in Mac OS X 10.7 (Lion). If so, select Go to Folderfrom the Go menu, type ~/Library in the text field, then click Go. Method 2 Hold the Command button and tap the Tab button until you have selected the Finder. Hold the Option key when you click on the Go menu, and you will see it below Home. Open the Users folder and then open your [username] folder with the house icon. Finally, open the Library folder and then the Preferences folder. Method 3 Open your hard drive by double-clicking the hard drive icon on your desktop. Open the Users folder and then open the folder with the house icon labelled with your [username]. Finally, open the Library folder and then the Preferences folder. In the Preferences folder, locate t
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us http://stackoverflow.com/questions/27370336/is-there-a-simpler-way-to-loop-for-error-checking-and-quitting-c-strings-chara Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow https://www.mathworks.com/matlabcentral/answers/82806-repeat-try-catch-loop Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Is there a simpler way to loop for error error checking checking and quitting? (C-strings/Character Arrays) [closed] up vote -1 down vote favorite I've been writing an assignment where we're tasked with making a shopping cart program that tracks the customer's cumulative price. I'm not allowed to use strings, global variables, or user defined functions I'm strictly instructed to use only Character arrays and loops. While my shopping cart program works fine, I was wondering if there is error checking loop any way to simplify my code? I feel like I would be penalized for making the code overly complicated. I feel like my quit feature in particular is overly complicated. Is there a better, simpler way of implementing it without using strings or functions? Sorry in advanced if it's very messy. #include
Support Answers MathWorks Search MathWorks.com MathWorks Answers Support MATLAB Answers™ MATLAB Central Community Home MATLAB Answers File Exchange Cody Blogs Newsreader Link Exchange ThingSpeak Anniversary Home Ask Answer Browse More Contributors Recent Activity Flagged Content Flagged as Spam Help MATLAB Central Community Home MATLAB Answers File Exchange Cody Blogs Newsreader Link Exchange ThingSpeak Anniversary Home Ask Answer Browse More Contributors Recent Activity Flagged Content Flagged as Spam Help Trial software Tom (view profile) 8 questions 0 answers 0 accepted answers Reputation: 2 Vote2 Repeat Try/Catch loop? Asked by Tom Tom (view profile) 8 questions 0 answers 0 accepted answers Reputation: 2 on 22 Jul 2013 Accepted Answer by Evan Evan (view profile) 13 questions 181 answers 95 accepted answers Reputation: 490 275 views (last 30 days) 275 views (last 30 days) I have code that sometimes results in an error, and sometimes not. I'd like to have the code run, and then if an error occurs try again until there is no error. Could this be done using a try/catch loop? I.e. the catch statement would tell the program to repeat the try statements? I'm not sure how to implement this.Thanks! 0 Comments Show all comments Tags loopstrycatchrepeat Products No products are associated with this question. Related Content 2 Answers Evan (view profile) 13 questions 181 answers 95 accepted answers Reputation: 490 Vote1 Link Direct link to this answer: https://www.mathworks.com/matlabcentral/answers/82806#answer_92443 Answer by Evan Evan (view profile) 13 questions 181 answers 95 accepted answers Reputation: 490 on 22 Jul 2013 Edited by Evan Evan (view profile) 13 questions 181 answers 95 accepted answers Reputation: 490 on 22 Jul 2013 Accepted answer