Question on project for useing Swicth statements and Loops

Hi im trying to design a looping swicth statement for my project. Basicly it ask a person to enter either A B C D or T T ends the loop. Then it should add up all of the items entered and give a grand total of the cost. However I am sort of new to programing, and have no idea how to finish my Code. I have attached what I have so far any ideas or corrections would be much appreicated.

// Lab 3 week 8 Created by David Warner on 2/28/11

#include <iostream>

using namespace std;

int main( )
{
int price = 0;
char item = '';
double totalcost = 0.0;

cout << "Enter item ordered A/B/C/D/T [T to stop]: ";
cin >> item;
item = toupper (item);

while (item != 'T')

switch (item)
{
case 'A' : cout << "Fried Chicken with slaw cost 4.25" << endl;
break;
case 'B' : cout << "Roast Beef with mashed potato cost 5.75" << endl;
break;
case 'C' : cout << "Fish and Chips cost 5.25" << endl;
break;
case 'D' : cout << "Soup and Salad cost 3.75" << endl;
break;
}

totalcost = Sum of A+B+C+D

{
cout << "Enter next item ordered [T to stop]: ";
cin >> item;

}
cout << "Total cost of meal: " << totalcost << endl;

system("pause");
return 0;
}
I think what you want is to add each price to totalcost each time they order one, not assume they ordered one of each (the syntax there is invalid anyway).
im not sure how i should make it look in my syntax like i said im not the best programer
Well now, I'm not going to do it for you. The rest of your code looks perfectly fine, which means one of two things:

* You are lazy, and don't want to make a few small changes
* You copied this code from somewhere and did a bit of editing, but have no idea what you are doing

I find it hard to believe you can make a switch statement but can't add some variables together.
At present, more and much more people decide on online buying.[url=http://www.nhljerseysshop.com] nhl jerseys [/url] Just while it’s appoint implies, online authentic Reebok jerseys shopping should be to conduct the actual shopping programs online. A very important reason to get online shopping is it delivers convenience into the life associated with people.
its my code its part of my homework a lot of times we start with a single code that is simple then each progresive question adds another thing to do it. Im just asking when you say add price. Do you mean price each one out seperatly as an interger?
1.)You need a default case for when a suitable case is not entered by the user
2.) How are you going to strip the price out of each case string?
3.) As Zhuge says you need to keep track of the running total with something like
totalcost+= item;
Topic archived. No new replies allowed.