error trap, and some more basics

Thread Solved

Join Date: Feb 2010
Posts: 60
Reputation: timbomo is an unknown quantity at this point 
Solved Threads: 0
timbomo timbomo is offline Offline
Junior Poster in Training

error trap, and some more basics

 
0
  #1
Feb 8th, 2010
Im trying to figure out how to error trap this program so if the user doesnt put in a valid response then a message will cum up and they will go back 2 the beginning until they do it correctly.

also i want to subtract the money they spend and tell them their remaining amount, also i want to keep track of the number of items they purchase.

when i do it all that comes up is a whole bunch of numbers.
can anyone help when you compile this program i want this format but the numbers arent right

can anyone help?

/* SIUE's bookstore is having aspecail sale on tiems embossed with the cougar logo. For a limited time, three items, mugs, teeshirts, and pens
are offered at a reduced rate with tax included to simplify the sales. Mugs are going for $2.50, teeshirts for $9.50 and pens for 75
cents. Coincidentally, your parents (or spouse, friend, coworker, or other person you know off-campus) just gave you $30.00 to buy SIUE
stuff for them.*/

#include<iostream>
using namespace std;
int main()
{
char symb;
int item_purch, numb_item_purch, quit;
double mug, teeshirt, pen, tot_mon, curr_cash, mon_spent;

cout << "What do you want to buy today?\n";
cout << "You have 30 dollars to spend.\n";


cout << " A) Mugs $2.50 " << endl;
cout << " B) teeshirt $9.50 " << endl;
cout << " C) Pens .75 cents " << endl;
cout << " D) Quit" << endl;
cout << " Enter your letter and press Return when finished" << endl;
cin >> symb;


switch (symb)
{
case 'A':;
case 'a':;
cout << " You have choosen A) mugs for $2.50 \n";
mug = 2.50;
cout << " You have " << curr_cash << " remaining \n ";
tot_mon = 30;
curr_cash = tot_mon - mug;
cout << " You have purchased " << numb_item_purch << " today \n ";
numb_item_purch = item_purch + 1;
break;
case 'B':;
case 'b':;
cout << " You have choosen B) teeshirt for $9.50 ";
teeshirt = 9.50;
break;
case 'C':;
case 'c':;
cout << " You have choosen C) Pens for .75 cents ";
pen = .75;
break;
case 'D':;
case 'd':;
cout << " You have choosen D) which means you want to Quit" << endl;
quit = 0;
break;
}



cin >> tot_mon;
curr_cash = tot_mon - mon_spent;
cin >> curr_cash;
cin >> mon_spent;




return 0;
}
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 4,304
Reputation: WaltP has a brilliant future WaltP has a brilliant future WaltP has a brilliant future WaltP has a brilliant future WaltP has a brilliant future WaltP has a brilliant future WaltP has a brilliant future WaltP has a brilliant future WaltP has a brilliant future WaltP has a brilliant future WaltP has a brilliant future 
Solved Threads: 412
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Industrious Poster
 
0
  #2
Feb 8th, 2010
I'll give you the benefit of time this time. You received an infraction warning about CODE tags 7 minutes before posting this. Last warning.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Feb 2010
Posts: 60
Reputation: timbomo is an unknown quantity at this point 
Solved Threads: 0
timbomo timbomo is offline Offline
Junior Poster in Training

code tags???

 
0
  #3
Feb 8th, 2010
Originally Posted by WaltP View Post
I'll give you the benefit of time this time. You received an infraction warning about CODE tags 7 minutes before posting this. Last warning.
what are the code tags ? i will put them on there if i knew how an error comes up when i do it. arent they just codes for people too type in so when someone to help people they use the code tags? r am i wrong?
just let me know cuz this site is pimp it helps me out alot
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 120
Reputation: tkud is an unknown quantity at this point 
Solved Threads: 23
tkud's Avatar
tkud tkud is offline Offline
Junior Poster

re

 
0
  #4
Feb 8th, 2010
You need to follow the rules, bro and use code tags otherwise majority of the folks here won't help you, except those who break rules like u just did.
"Show me your code and I will tell you who you are.."-Tkud
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 120
Reputation: tkud is an unknown quantity at this point 
Solved Threads: 23
tkud's Avatar
tkud tkud is offline Offline
Junior Poster
 
0
  #5
Feb 8th, 2010
Originally Posted by timbomo View Post
what are the code tags ? i will put them on there if i knew how an error comes up when i do it. arent they just codes for people too type in so when someone to help people they use the code tags? r am i wrong?
just let me know cuz this site is pimp it helps me out alot
When you're writing a post, take a look at the bar on top where some cotrols for easy readability are placed. You would see something like this mong them:
[CODE]

Click on it, then something like this would appear:
Then, type your code in between them and that's it!
"Show me your code and I will tell you who you are.."-Tkud
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 4,304
Reputation: WaltP has a brilliant future WaltP has a brilliant future WaltP has a brilliant future WaltP has a brilliant future WaltP has a brilliant future WaltP has a brilliant future WaltP has a brilliant future WaltP has a brilliant future WaltP has a brilliant future WaltP has a brilliant future WaltP has a brilliant future 
Solved Threads: 412
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Industrious Poster
 
0
  #6
Feb 8th, 2010
Originally Posted by timbomo View Post
what are the code tags ? i will put them on there if i knew how an error comes up when i do it. arent they just codes for people too type in so when someone to help people they use the code tags? r am i wrong?
just let me know cuz this site is pimp it helps me out alot
Read your PM.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Reply

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




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



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

©2003 - 2010 DaniWeb® LLC