borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (how to get shapes name/type in word?)Next Topic (Compiler) New Topic New Poll Post Reply
AndreaVB Forum : C# : Please help with problem with my total
Poster Message
imxelite
Level: Protégé

Registered: 01-10-2005
Posts: 4

icon Please help with problem with my total

Hi,

I was having trouble calculating my total for a menu I'm trying to make for class. Could someone look at the code below and tell how do I go about making the computer total what the user enters?

#include <iostream>
#include <string>
using namespace std;
string Rye, Wheat, White, Sourdough, Pumpernickel;
string Ham, Beff, Reuben, PBJ, Cheese, Vegetarian;
string Mayo, Mustard, Ketchup, None;
string Coke, Diet, Tea, Coffee, Water;
double coke = 1.25, diet = 1.25, tea = 1.00, coffee = 1.00, water = 1.00;
int main()
{
cout << "Welcome to the Sandwich Corral" << endl;
cout << "You will be given choices for building your sandwich." << endl;
cout << "Please enter your selection after each prompt and then press " <<
"the enter key."<< endl;
cout << "Please enter your meat choice:"<< endl;
cout << "Ham," " Beef," " Reuben," " PBJ," " Cheese," " or" " Vegetarian"<< endl;
cin >> Ham, Beff, Reuben, PBJ, Cheese, Vegetarian;
cout << "Please enter your bread choice:"<< endl;
cout << "Rye," "Wheat," "White," "Sourdough," "or Pumpernickel"<< endl;
cin >> Rye, Wheat, White, Sourdough, Pumpernickel;
cout << " Please enter your choice of condiment (one only):"<< endl;
cout << "Mayo, Mustard, Ketchup, or None:"<< endl;
cin >> Mayo, Mustard, Ketchup, None;
cout << "Please enter your drink choice" << endl;
cout << "Coke, Diet, Tea, Coffee, or Water:" << endl;
cin >> Coke, Diet, Tea, Coffee, Water;
cout << "Please enter 3.99 for a half sandwich or 5.99 for a whole" <<
cout << " sandwich: 3.99"<< endl;
cout << "You have entered the following information:"<< endl;
cout << "Sandwich:"<< endl;
cout << "Bread:"<< endl;
cout << "Condiment:"<< endl;
cout << "Drink:"<< endl;
cout << "Tab:"<< endl;

return 0;
}

[Edited by imxelite on 01-10-2005 at 01:00 AM GMT]

01-10-2005 at 06:00 AM
View Profile Send Email to User Show All Posts | Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 891
icon Re: Please help with problem with my total

Hi,
What is this program supposed to do?
You only have costs for the drinks.

The code below illustrates how you should do this sort of thing:

// KW Altered
//cin >> Ham, Beff, Reuben, PBJ, Cheese, Vegetarian;
cin >> MeatChoice;
if (MeatChoice=="Ham") {
meat_cost = 1.99;
}else {
if (MeatChoice=="Beff") {
meat_cost= 2.99;
}else {
if (MeatChoice=="Reuben") {
meat_cost= 2.59;
}
}
}
cout << "Your sandwish costs about " << meat_cost << endl;


Hope this helps,
Kieron

____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)

01-10-2005 at 06:55 PM
View Profile Send Email to User Show All Posts | Quote Reply
imxelite
Level: Protégé

Registered: 01-10-2005
Posts: 4
icon Re: Please help with problem with my total

quote:
stickleprojects wrote:
Hi,
What is this program supposed to do?
You only have costs for the drinks.

The code below illustrates how you should do this sort of thing:

// KW Altered
//cin >> Ham, Beff, Reuben, PBJ, Cheese, Vegetarian;
cin >> MeatChoice;
if (MeatChoice=="Ham") {
meat_cost = 1.99;
}else {
if (MeatChoice=="Beff") {
meat_cost= 2.99;
}else {
if (MeatChoice=="Reuben") {
meat_cost= 2.59;
}
}
}
cout << "Your sandwish costs about " << meat_cost << endl;


Hope this helps,
Kieron


I was trying to just have it were it tells the person what they picked on their sandwich also the cost of the sandwich was based on if it was half or whole.
01-10-2005 at 08:21 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : C# : Please help with problem with my total
Previous Topic (how to get shapes name/type in word?)Next Topic (Compiler) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder