error checking help

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2007
Posts: 3
Reputation: gmoli is an unknown quantity at this point 
Solved Threads: 0
gmoli gmoli is offline Offline
Newbie Poster

error checking help

 
0
  #1
Sep 11th, 2007
I need to error check a user input and it must be a value between 0 and 13 whole numbers only. it will be stored in a int variable using the cin function. I dont remember how to do this since i have not taken a c++ course in 3 years. This assignment is using top down progamming, not object oriented programming.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 1,169
Reputation: Duki has a spectacular aura about Duki has a spectacular aura about Duki has a spectacular aura about 
Solved Threads: 9
Duki's Avatar
Duki Duki is offline Offline
Veteran Poster

Re: error checking help

 
0
  #2
Sep 11th, 2007
perhaps this will help jog your memory
Last edited by Duki; Sep 11th, 2007 at 2:03 pm.
It is practically impossible to teach good programming style to students that have had prior exposure to Basic; as potential programmers they are mentally mutilated beyond hope of regeneration.

-Edsger Dijkstra
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 3
Reputation: gmoli is an unknown quantity at this point 
Solved Threads: 0
gmoli gmoli is offline Offline
Newbie Poster

Re: error checking help

 
0
  #3
Sep 11th, 2007
Originally Posted by Duki View Post
perhaps this will help jog your memory

I looked at the tutoral and have not seen anything about error checking i think I have the basic concept of c++ I have completed the top down course at my school. I am now enrolled in opject oriented programing class. My first assigment is a review from my last class and my notes on error checking are terrible. that is my fault but i dont have anything to look at to see how to set this one up. any help you can give would be greatly appriciated. I am not sure what this text box means by surround code could you briefly explain this to me as well. this is the first time i have ever posted a thread. thankyou soo much.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 1,169
Reputation: Duki has a spectacular aura about Duki has a spectacular aura about Duki has a spectacular aura about 
Solved Threads: 9
Duki's Avatar
Duki Duki is offline Offline
Veteran Poster

Re: error checking help

 
0
  #4
Sep 11th, 2007
when/if you paste any of your code in a reply you need to do it like this

[code.]

\\code goes here

[/code.]

of course, you want to take out the '.' after the word code which makes your reply look like this:

  1.  
  2. #include <iostream>
  3. ...
  4. return 0 ;
etc.


As for the error checking, consider this. If you wanted to check that 'x' is less than 10 but greater than 0, you could use the following construct:

  1. if ( x > 0 && x < 10 )
  2. cout << "Excellent!" << endl ;
  3. else
  4. {
  5. cout << "Invalid Input!! -- Exiting program!!" << endl ;
  6. exit ( 1 ) ;
  7. }

So now, what else could you check with the if/else statements and how?
Does this help any?
It is practically impossible to teach good programming style to students that have had prior exposure to Basic; as potential programmers they are mentally mutilated beyond hope of regeneration.

-Edsger Dijkstra
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 3
Reputation: gmoli is an unknown quantity at this point 
Solved Threads: 0
gmoli gmoli is offline Offline
Newbie Poster

Re: error checking help

 
0
  #5
Sep 11th, 2007
yes i was just going about it from the wrond direction very helpfull thankyou very much for your time and wisdom
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 1,169
Reputation: Duki has a spectacular aura about Duki has a spectacular aura about Duki has a spectacular aura about 
Solved Threads: 9
Duki's Avatar
Duki Duki is offline Offline
Veteran Poster

Re: error checking help

 
0
  #6
Sep 11th, 2007
welcome.
It is practically impossible to teach good programming style to students that have had prior exposure to Basic; as potential programmers they are mentally mutilated beyond hope of regeneration.

-Edsger Dijkstra
Reply With Quote Quick reply to this message  
Reply

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




Views: 639 | Replies: 5
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC