very new to c++

Ok, I have made adjustments to this and I am still getting all sorts of errors....like "item" is an undeclared identifier. and size is undeclared identifier..that kidn of thing...so what the HECK am I doing wrong!?!?!?!!

Thanks for any assistance I can get!


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include <algorithm>
#include <iostream>
#include <string>
#include <iomanip>

using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::fixed;

 int main()

{

//declare variables

char Lemonade='l'; 
int lg_ade= 'lg';
char sm_ade ='s';
char Cookie ='c'; 
int c_cookie ='cc';
char o_cookie ='o';
char tshirt ='t';
char a_tshirt ='a';
char n_tshirt ='n';
int tot_trans = 0;
double tot_oz = 0.0; 
int tot_c_cookie=0;
int tot_o_cookie= 0;
int tot_a_tshirt=0;
int tot_n_tshirt=0;
double tot_sales = 0.0; 
double bid =0.0; 
double highest_bid=0.0;
char sentinel ='q';
char item;
char choice;
char size;
char type;

//get user's input 

cout << "Welcome To Your Lemonade Stand! \n\n";
cout << "Ok, Today's selections consist of Cookies, Chocolate Chip or Oatmeal. \n\n"
"Two sizes of Lemonade, Large which is 16 oz and Small \n\n"
"which is 12 oz. And special for today, we have two t-shirts! \n\n"
"One is autographed by the This Old House crew and the other is plain.\n\n";
cout<< "\n\nPlease enter a L for lemonade\n\n"
"Please enter C for cookie\n\n"
"Please enter T for tshirt\n\n"
"if you wish to quit this program, please press the 'Q' on your keyboard. \n\n";

while item!='q'&&
item!='l'&&
item!='c'&&
item!='t'

getline(cin, item);
transform(item.begin(), item.end(), item.begin(),toupper);

cout<<"Invalid Entry. Please try again.\n\n";
{
cout<<"If you would like to purchase Lemonade, enter a L to select. \n\n"
"If you would like to purchase a Cookie, please enter a C to select. \n\n"
"If you would like to purchase a T-shirt, please enter a T to select. \n\n";
cin>> item;
item=toupper(item);
if (item==l)
{

cout<<"Enter S for a small lemonade.\n\n"
cin>> size;
cout<<fixed;setrprecision(2);
cout << "Your total is $1.50 \n\n";
cin>> tot_oz+=1;
cin>> tot_sales+=1.50;
}
else if (size==lg)
{
cout<< "Your total is $2.00. \n\n";
cin>> tot_oz+=16;
cin>> tot_sales+=2.00;
}
else if (item==C)
{
cout<<"Enter O for an Oatmeal cookie or CC for a chocolate chip cookie.\n\n";
cin>> type;
cout<<fixed;setrprecision(2);
cout << "Your total is $0.75 \n\n";
cin>> tot_o_cookie+=1;
cin>> tot_sales+=.75;
}
else if (size==CC)
{
cout<< "Your total is $0.75. \n\n";
cin>> tot_c_cookie+=1;
cin>> tot_sales+=.75;
}
else if (item==T)
{
cout<<"Enter A for an Autographed T-Shirt.\n\n";
cin>> type;
cout<<fixed;setrprecision(2);
cout << "Your total is $15.00 \n\n";
cin>> tot_a_tshirt+=1;
cin>> tot_sales+=15.00;

}
else (size==N)
{
cout<< "Your total is $8.00. \n\n";
cin>> tot_n_tshirt+=1;
cin>> tot_sales+=8.00;
} end while

//display menu again Of course this is incomplete!

return(0);

}
Last edited on
your while comand is without a )
closed account (z05DSL3A)
It has got a ')' it's about four lines down (from while).

It looks like it is missing { and } arould the block of code you are trying to put in the while loop, as a result it will only loop the getline(cin, item);

I have only give this a cursory glance, but there dose seem to be quite allot wrong.

To start with you need for format your code and/or make sure it stays formatted when posting.
Last edited on
At a glance, I could say that your item is declared as string and compared as a single char and in all if conditional checks the quotes around string literals are missing.
First, change this:
while (item!='Q'&& item!='L'&& item!='C'&& item!='T')

to:
while (item!="Q" && item!="L"&& item!="C" && item!="T")

and change all if conditional literal checks with enclosed quotes like:

if (item=="L")
else if (item=="lg")
else if (item=="C")
else if (item=="CC")



Try it out with recompiling the code and check it out. If it still fails, you better check line by line with other compiler errors.

Good luck :)

i think.....

cout << "Ok, Today's selections consist of Cookies, Chocolate Chip or Oatmeal. \n\n"
<<"Two sizes of Lemonade, Large which is 16 oz and Small \n\n"<<
"which is 12 oz. And special for today, we have two t-shirts! \n\n"<<
"One is autographed by the This Old House crew and the other is plain.\n\n";

extraction operator sud be inserted more than once...i e cascading.....
Topic archived. No new replies allowed.