Function with parameters

Pages: 12
If you don't need switch yes you can use if :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
while (item != 8)
{
     // Display enter item until 8 is selected
cout << "Enter Menu Item: ";
    cin >> item; cout << endl;

    if(item == 1) total += 6.00; else
    if(item == 2) total += 4.50; else
    if(item == 3) total += 3.75; else
    if(item == 4) total += 5.50; else
    if(item == 5) total += 2.80; else
    if(item == 6) total += 1.00; else
    if(item == 7) total += 2.00;
    }
}
Topic archived. No new replies allowed.
Pages: 12