problem in calculation of sum of user input and how many time a userinput data.

#include <iostream.h>
void f(int);
int main ()
{
int mealprice;
int i, userinput[10];
int salestax;
int totalamounts;
int totalamount[10];
int totalamountofbill=0;
i=0;
char c;
cout << endl << "*** Virtual Restaurant ***" << endl;
cout << endl;
cout << "Enter the price of meal: ";
for(i=0;i<10;i++)
{
if (totalamounts=mealprice+salestax)
{
totalamount[i]=totalamounts;
userinput[i]=totalamount[i];
for(i=0;i<10;i++)
{
if(totalamounts!=-1)
{
totalamount[i]=totalamounts;
}
totalamountofbill=totalamountofbill+totalamounts;
totalamounts=totalamounts++;
}
do
{
cin >> mealprice;
if(mealprice!=-1)
{
userinput[i]=mealprice;
}i++;
}while(mealprice!=-1 && i<10);
if(mealprice<=1000)
{
salestax=(mealprice*0/100);
totalamounts=mealprice+salestax;
}
if(mealprice>1000&&mealprice<=2000)
{
salestax=mealprice*1/100;
totalamounts=mealprice+salestax;
}
if(mealprice>2000)
{
salestax=mealprice*2/100;
totalamounts=mealprice+salestax;
}
cout <<"Meal Price: "<< mealprice <<'\n';
cout <<"Sales Tax: "<< salestax <<'\n';
cout <<"------------------------------"<<'\n';
cout <<"Total Amount: "<< totalamounts<<'\n';
if(totalamounts<1000)
{
cout << "This customer should be served with Candies"<<'\n';
}
if(totalamounts>=1000 && totalamounts<2000)
{
cout << "This customer should be served with Sweet Bread"<<'\n';
}
if(totalamounts>=2000 && totalamounts<3000)
{
cout << "This customer should be served with Puding"<<'\n';
}
if(totalamounts>=3000 && totalamounts<4000)
{
cout << "This customer should be served with Cake"<<'\n';
}
if(totalamounts>4000)
{
cout << "This customer should be served with Trifle"<<'\n';
}
cout << "Do you want to enter the other customer?" << endl;
cout << "Press 'Y' to continue or 'N' to Exit: ";
do
{

cin >> c;
if (c=='y'||c=='Y')
{
main();
int i=0;
}
if (c=='n'||c=='N')
{
cout << "Grand Total: " << '\n';
cout << '\n';
cout << "Total Customers: " << i-1 <<'\n';
cout << "Total Amount of Bills: " << totalamountofbill<< '\n';
return 1;
}
}while(c!='n'||c!='N');
}
}
return 0;
}
Last edited on
Topic archived. No new replies allowed.