I am writting the fallowing program: The program is working find; however I can't get the funciton to calculate the total and the tax. can someome help me please.

Here is the code...

#include<iostream>
#include<string>
#include<iomanip>
void showMenu();
using namespace std;
const int menu = 1;
struct menuItemType
{
string menuItem;
double menuPrice;
};
void getData(menuItemType placeorder[8]);
void printCheck(menuItemType printorder[]);
int main()
{
showMenu();
menuItemType menuList[8];
menuItemType order[8];
getData(order);
printCheck(order);
return 0;
}
void showMenu()
{
cout <<"-------------------------------------------------"<<endl;
cout <<" Please place your order: "<<endl;
cout <<"-------------------------------------------------"<<endl;
cout <<"1. Plain Egg..............$1.45 "<<endl;
cout <<"2. Bacon and Egg..........$2.45 "<<endl;
cout <<"3. Muffin.................$0.99 "<<endl;
cout <<"4. French Toast...........$1.99 "<<endl;
cout <<"5. Fruit Basket...........$2.49 "<<endl;
cout <<"6. Cereal.................$0.69 "<<endl;
cout <<"7. Coffee.................$0.50 "<<endl;
cout <<"8. Tea....................$0.75 "<<endl;
cout <<"------------------------------------------------"<<endl;
}
void getData(menuItemType placeorder[8])
{
menuItemType menuList[8];
menuList[0].menuItem ="Plain Egg";
menuList[1].menuItem ="Bacon and Egg";
menuList[2].menuItem ="Muffin";
menuList[3].menuItem ="French Toast";
menuList[4].menuItem ="Fruit Basket";
menuList[5].menuItem ="Cereal";
menuList[6].menuItem ="Coffee";
menuList[7].menuItem ="Tea";
menuList[0].menuPrice =1.45;
menuList[1].menuPrice =2.45;
menuList[2].menuPrice=0.99;
menuList[3].menuPrice=1.99;
menuList[4].menuPrice=2.49;
menuList[5].menuPrice=0.69;
menuList[6].menuPrice=0.50;
menuList[7].menuPrice=0.75;
for(int x=0;x<2;x++)
{
cout << "What do you want chose 1 thought 8: " << endl;
int answer;
cin >> answer;
cout << "How many : " << endl;
int howmany;
cin >> howmany;
placeorder[x].menuItem = menuList[answer-1].menuItem;
placeorder[x].menuPrice = menuList[answer-1].menuPrice *howmany;
}
}
void printCheck(menuItemType printorder[])
{
double amountDue = 0;
double tax = .05;
double TotalDue = 0;
int x=0;
cout <<"-------------------------------------------------"<<endl;
cout<<" Welcome to Johnny's Restaurant"<<endl;
cout <<"-------------------------------------------------"<<endl;
for(int x=0;x<2;x++)
{
cout<<printorder[x].menuItem<<setw(8)<<printorder[x].menuPrice<<endl;
}
cout<<"\nAmount Due.........$"<<amountDue<<endl<<endl;
cout<<"Tax................$"<<tax<<endl<<endl;
cout<<"Total Amount Due...$"<<amountDue<<endl;
}

And that needed a Poll?

I am writting the fallowing program: The program is working find; however I can't get the funciton to calculate the total and the tax. can someome help me please.
Here is the code...

#include<iostream>
#include<string>
#include<iomanip>
void showMenu();
usingnamespace std;
constint menu = 1;
struct menuItemType
{
string menuItem;
double menuPrice;
};
void getData(menuItemType placeorder[8]);
void printCheck(menuItemType printorder[]);
int main()
{
showMenu();
menuItemType menuList[8];
menuItemType order[8];
getData(order);
printCheck(order);
return 0;
}
void showMenu()
{
cout <<"-------------------------------------------------"<<endl;
cout <<" Please place your order: "<<endl;
cout <<"-------------------------------------------------"<<endl;
cout <<"1. Plain Egg..............$1.45 "<<endl;
cout <<"2. Bacon and Egg..........$2.45 "<<endl;
cout <<"3. Muffin.................$0.99 "<<endl;
cout <<"4. French Toast...........$1.99 "<<endl;
cout <<"5. Fruit Basket...........$2.49 "<<endl;
cout <<"6. Cereal.................$0.69 "<<endl;
cout <<"7. Coffee.................$0.50 "<<endl;
cout <<"8. Tea....................$0.75 "<<endl;
cout <<"------------------------------------------------"<<endl;
}
void getData(menuItemType placeorder[8])
{
menuItemType menuList[8];
menuList[0].menuItem ="Plain Egg";
menuList[1].menuItem ="Bacon and Egg";
menuList[2].menuItem ="Muffin";
menuList[3].menuItem ="French Toast";
menuList[4].menuItem ="Fruit Basket";
menuList[5].menuItem ="Cereal";
menuList[6].menuItem ="Coffee";
menuList[7].menuItem ="Tea";
menuList[0].menuPrice =1.45;
menuList[1].menuPrice =2.45;
menuList[2].menuPrice=0.99;
menuList[3].menuPrice=1.99;
menuList[4].menuPrice=2.49;
menuList[5].menuPrice=0.69;
menuList[6].menuPrice=0.50;
menuList[7].menuPrice=0.75;
for(int x=0;x<2;x++)
{
cout << "What do you want chose 1 thought 8: " << endl;
int answer;
cin >> answer;
cout << "How many : " << endl;
int howmany;
cin >> howmany;
placeorder[x].menuItem = menuList[answer-1].menuItem;
placeorder[x].menuPrice = menuList[answer-1].menuPrice *howmany;
}
}
void printCheck(menuItemType printorder[])
{
double amountDue = 0;
double tax = .05;
double TotalDue = 0;
int x=0;
cout <<"-------------------------------------------------"<<endl;
cout<<" Welcome to Johnny's Restaurant"<<endl;
cout <<"-------------------------------------------------"<<endl;
for(int x=0;x<2;x++)
{
cout<<printorder[x].menuItem<<setw(8)<<printorder[x].menuPrice<<endl;
}
cout<<"\nAmount Due.........$"<<amountDue<<endl<<endl;
cout<<"Tax................$"<<tax<<endl<<endl;
cout<<"Total Amount Due...$"<<amountDue<<endl;
}

Here is the Complete Working Program, although, judging from when it was posted, you might not need it, it may help someone else:


#include<iostream>
#include<string>
#include<iomanip>
using namespace std;


const int menu = 1;


void showMenu();
int done=0;


struct menuItemType  // Struct Definition
{
string menuItem; // Member of Struct
double menuPrice; // Member of Struct
};


void getData(menuItemType placeorder[8]); // getData Function for placeorder


void printCheck(menuItemType printorder[]); // output function for placeorder


int main()
{
showMenu(); // function call
menuItemType menuList[8]; // Struct Member call
menuItemType order[8]; // Struct Member call
getData(order); // function call
printCheck(order); // function call


return 0;
}


void showMenu() // Main Menu
{
cout <<"-------------------------------------------------"<<endl;
cout <<"Welcome to Johnny's Restaurant" << endl;
cout <<"-------------------------------------------------"<<endl;
cout <<"This is Today's Menu, What would You Like?: "<<endl;
cout <<"-------------------------------------------------"<<endl;
cout <<"Item#   Choice              Price " << endl;
cout <<"__________________________________" << endl;
cout <<"  1. Plain Egg..............$1.45 "<<endl;
cout <<"  2. Bacon and Egg..........$2.45 "<<endl;
cout <<"  3. Muffin.................$0.99 "<<endl;
cout <<"  4. French Toast...........$1.99 "<<endl;
cout <<"  5. Fruit Basket...........$2.49 "<<endl;
cout <<"  6. Cereal.................$0.69 "<<endl;
cout <<"  7. Coffee.................$0.50 "<<endl;
cout <<"  8. Tea....................$0.75 "<<endl;
cout <<"------------------------------------------------"<<endl;
}
void getData(menuItemType placeorder[8]) // Item choices and prices Declared
{
menuItemType menuList[8];
menuList[0].menuItem ="Plain Egg";
menuList[1].menuItem ="Bacon and Egg";
menuList[2].menuItem ="Muffin";
menuList[3].menuItem ="French Toast";
menuList[4].menuItem ="Fruit Basket";
menuList[5].menuItem ="Cereal";
menuList[6].menuItem ="Coffee";
menuList[7].menuItem ="Tea";
menuList[0].menuPrice =1.45;
menuList[1].menuPrice =2.45;
menuList[2].menuPrice=0.99;
menuList[3].menuPrice=1.99;
menuList[4].menuPrice=2.49;
menuList[5].menuPrice=0.69;
menuList[6].menuPrice=0.50;
menuList[7].menuPrice=0.75;


cout << "How many items would you like to order? "; // Find out how many items needed
cin >> done; // store the amount of items needed
cout << " " << endl;
for(int x=0;x<done;x++) // loop to determine the choices and quantity
{
int answer;
int howmany;


cout << "What Menu Item would you Like? - #"; // request item number
cin >> answer; // store result
cout << "How many : "; // request quantity of item number
cin >> howmany; // store quantity
cout << " " << endl;


placeorder[x].menuItem = menuList[answer-1].menuItem;
placeorder[x].menuPrice = menuList[answer-1].menuPrice *howmany;
}


}


void printCheck(menuItemType printorder[]) // output function
{
double amountDue = 0;
double tax = 5.00;
double TotalDue = 0;
int x;


cout << "------------------------------------------------" << endl;
cout << " " << endl;
cout << " ****** Your Order is as Follows ******" << endl; // details heading
cout << " " << endl;
cout <<"-------------------------------------------------"<<endl;


for(x=0;x<done;x++)
{
cout<<printorder[x].menuItem<<setw(8)<<printorder[x].menuPrice<<endl;
amountDue = amountDue + (printorder[x].menuPrice);
}
cout << "=======================" << endl;
TotalDue = (amountDue/tax) + amountDue;
cout<<"SubTotal.........$"<<amountDue<<endl<<endl;
cout<<"** Tax Calculated at 5% **" << endl;
cout<<"Tax................$"<<amountDue/tax<<endl<<endl;
cout<<"Total Amount Due...$"<<TotalDue<<endl;
cout << " " << endl;
}

and thanks for most of the code, I modified it to fit my model.

commented: Try using code tags, reading intro threads, and checking that posts are not 9 months old :( -1

Arrrgh, It burns! Learn how to use CODE TAGS

commented: Rep++ from --salem ;) +6
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.