# Thread: Multiple If Statements Question.

1. ## Multiple If Statements Question.

Hello,
Here is what I am writing a program for. I have my code at the bottom of the page, along with the listed errors I receive when executing the program. It would be greatly appreciated if anyone could take a look and give me some pointers.

I am writing a program which allows the user to choose a beverage, sandwich and side order from a menu. After the choices are made, the program should do the following:

* list the items chosen with the cost of each item
* the sub-total of just the items
* the total cost including tax (use 6.5% for the tax).

The following are the items and prices I will include:

Beverages:

1: Soda: \$0.99
2: Milk: \$0.79
3: Juice: \$1.29

Sandwiches:

1: Hamburger: \$0.99
2: Cheeseburger: \$1.09
3: Chicken Sandwich: \$2.59

Side Orders:

1: French Fries: \$0.89
2: Onion Rings: \$1.09
3: Corn Chips: \$0.59

The output should look something like this (it must include the items and prices, the sub-total, the tax, and the total cost including tax)

Soda: \$0.99
Hamburger: \$0.99
French Fries: \$0.89

Total of food: \$2.87
Tax: \$0.19
Total for order: \$3.06

So, Here is the code, it would be appreciated if anyone could give me some advice and pointers on what to do. Thanks!
Code:
```#include <iostream>
#include <string>
int main()
{
string x;
string y;
string z;
double a;
double b;
double c;

string Soda;
string Milk;
string Juice;
string Fries;
string Onion Rings;
string Chips;
string Hamburger;
string Cheeseburger;
string Chicken;

Soda = .99;
Milk = .79;
Juice = 1.29;
Fries =.89;
Onion Rings = 1.09;
Chips =.59;
Hamburger =.99;
Cheeseburger = 1.09;
Chicken = 2.59;

a = x + y + z;
b = a * .065;
c = a + b;

cout << "Enter Beverage:" << endl;
cout << "Soda: \$0.99" << endl;
cout << "Milk: \$0.79" << endl;
cout << "Juice: \$1.29" << endl;
cin >> x;
cout << "Enter Sandwich:" << endl;
cout << "Hamburger: \$0.99" << endl;
cout << "Cheeseburger: \$1.09" << endl;
cout << "Chicken: \$2.59" << endl;
cin >> y;
cout << "Enter Side:" << endl;
cout << "Fries: \$0.89" << endl;
cout << "Onion Rings: \$1.09" << endl;
cout << "Chips: \$0.59" << endl;
cin >> z;

return 0;
}```
Here are the errors...
Code:
```C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(8) : error C2065: 'string' : undeclared identifier
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(8) : error C2146: syntax error : missing ';' before identifier 'x'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(8) : error C2065: 'x' : undeclared identifier
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(9) : error C2146: syntax error : missing ';' before identifier 'y'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(9) : error C2065: 'y' : undeclared identifier
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(10) : error C2146: syntax error : missing ';' before identifier 'z'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(10) : error C2065: 'z' : undeclared identifier
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(15) : error C2146: syntax error : missing ';' before identifier 'Soda'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(15) : error C2065: 'Soda' : undeclared identifier
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(16) : error C2146: syntax error : missing ';' before identifier 'Milk'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(16) : error C2065: 'Milk' : undeclared identifier
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(17) : error C2146: syntax error : missing ';' before identifier 'Juice'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(17) : error C2065: 'Juice' : undeclared identifier
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(18) : error C2146: syntax error : missing ';' before identifier 'Fries'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(18) : error C2065: 'Fries' : undeclared identifier
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(19) : error C2146: syntax error : missing ';' before identifier 'Onion'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(19) : error C2065: 'Onion' : undeclared identifier
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(19) : error C2146: syntax error : missing ';' before identifier 'Rings'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(19) : error C2065: 'Rings' : undeclared identifier
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(20) : error C2146: syntax error : missing ';' before identifier 'Chips'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(20) : error C2065: 'Chips' : undeclared identifier
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(21) : error C2146: syntax error : missing ';' before identifier 'Hamburger'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(21) : error C2065: 'Hamburger' : undeclared identifier
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(22) : error C2146: syntax error : missing ';' before identifier 'Cheeseburger'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(22) : error C2065: 'Cheeseburger' : undeclared identifier
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(23) : error C2146: syntax error : missing ';' before identifier 'Chicken'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(23) : error C2065: 'Chicken' : undeclared identifier
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(29) : error C2146: syntax error : missing ';' before identifier 'Rings'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(39) : error C2065: 'cout' : undeclared identifier
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(39) : error C2297: '<<' : illegal, right operand has type 'char [16]'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(39) : error C2065: 'endl' : undeclared identifier
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(40) : error C2297: '<<' : illegal, right operand has type 'char [12]'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(41) : error C2297: '<<' : illegal, right operand has type 'char [12]'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(42) : error C2297: '<<' : illegal, right operand has type 'char [13]'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(43) : error C2065: 'cin' : undeclared identifier
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(43) : warning C4552: '>>' : operator has no effect; expected operator with side-effect
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(44) : error C2297: '<<' : illegal, right operand has type 'char [16]'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(45) : error C2297: '<<' : illegal, right operand has type 'char [17]'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(46) : error C2297: '<<' : illegal, right operand has type 'char [20]'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(47) : error C2297: '<<' : illegal, right operand has type 'char [15]'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(48) : warning C4552: '>>' : operator has no effect; expected operator with side-effect
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(49) : error C2297: '<<' : illegal, right operand has type 'char [12]'
C:\Documents and Settings\Active Source\DESKTOP\test\test.cpp(50) : error C2297: '<<' : illegal, right operand has type 'char [13]'```
Any ideas on what I should do now?
Should I just start over a do it a certain way?
Any input would be greatly appreciated, thank you very much!

2. cout, cin and string lies in the std namespace, so they must be prefixed with std::.
std::cout, std::cin, std::string, std::endl.

3. Like this:

Code:
```#include <iostream>
#include <string>

using namespace std; //Use this so you don't have to use the prefix std::

int main()
{
string x;
string y;
string z;
double a;
double b;
double c;
.
.
.
.```

4. It is possible using that approach too, yes, but many recommend prefixing before the using, to avoid name collisions.