[prog] switch statement
Kathryn Hogg
kjh at flyballdogs.com
Thu Dec 16 14:45:09 EST 2004
Wolf Rising said:
> Is this what you meant?
Not quite you need to do a loop like this:
do {
// get a valid product number
product = 0; // initialize to zero incase we get EOF
cout << "Product number" << endl;
cin >> product;
switch (product) {
case 0:
break;
case 1:
price = ....;
....
default:
cout << "invalid product number" << endl;
break;
}
// if its a good product
if (product > 0 && product < 6) {
// get quantity
...
// calculate total
total += quantity * price;
}
} while (product != 0);
cout << "total = " << total << endl;
--
Kathryn
http://womensfooty.com
More information about the Programming
mailing list