hello could you help me to modify my code below 1. Round the total sum of the order to the nearest 5 sen. refer https://www.bnm.gov.my/misc/-/asset_publisher/2BOPbOBfILtL/content/about-the-rounding-mechanism #include using namespace std; void menu() { cout << "******Welcome to the Farhan's Restaurant******" << endl; cout<<"_________________________________________________"<= 65 && charASCII <= 90) || (charASCII >= 97 && charASCII <= 122) || charASCII == 32) { //do nothing } else { invalid = true; } } if (!invalid) break; cout << "Invalid Name try again!!\n"; } cout<<"Please enter your phone number :"; cin>>phone; float jum; string promo; int n; int qty[7]; int no[7]; long price[7],tot[4]; string name[7]; float change,pay,discount; menu(); cout<<""<>n; if(n>0 && n<=7) //loop for menus { for(int i=0; i>pay; cout<<"Do you have a promo code?"<>promo; change=pay-jum; cout<<"________________________________"<
hello could you help me to modify my code below
1. Round the total sum of the order to the nearest 5 sen. refer https://www.bnm.gov.my/misc/-/asset_publisher/2BOPbOBfILtL/content/about-the-rounding-
#include <iostream>
using namespace std;
void menu()
{
cout << "******Welcome to the Farhan's Restaurant******" << endl;
cout<<"_________________________________________________"<<endl;
cout<<"No. Menu Price"<<endl;
cout<<"1. Cheese Burger RM 8"<<endl;
cout<<"2. Chicken Wings(6 pieces) RM 10"<<endl;
cout<<"3. 12\" Pepperoni Pizza RM 20"<<endl;
cout<<"4. Fries RM 5"<<endl;
cout<<"5. Onion Rings RM 6"<<endl;
cout<<"6. Pepsi RM 2"<<endl;
cout<<"7. Mineral Water RM 3"<<endl;
}
main()
{
string phone; //we use string so that the 0 value can be displayed
string Name;
while (1)
{
cout << "Please Enter the customer's Name:";
getline(cin,Name); //to ensure we can input two names at once
bool invalid = false;
for (int i = 0; i < Name.length(); i++)
{
int charASCII = Name[i];
if ((charASCII >= 65 && charASCII <= 90) || (charASCII >= 97 && charASCII <= 122) || charASCII == 32)
{
//do nothing
}
else
{
invalid = true;
}
}
if (!invalid)
break;
cout << "Invalid Name try again!!\n";
}
cout<<"Please enter your phone number :";
cin>>phone;
float jum;
string promo;
int n;
int qty[7];
int no[7];
long price[7],tot[4];
string name[7];
float change,pay,discount;
menu();
cout<<""<<endl;
cout<<"How many types of menu do you want: ";
cin>>n;
if(n>0 && n<=7) //loop for menus
{
for(int i=0; i<n;i++)
{
cout<<"Enter your choice "<<i+1<<"=";
cin>>no[i];
cout<<"Enter quantity =";
cin>>qty[i];
if(no[i]==1)
{
name[i]="Cheese Burger";
price[i]=8;
tot[i]=price[i]*qty[i];
}
else if(no[i]==2)
{
name[i]="Chicken Wings(6 pieces)";
price[i]=10;
tot[i]=price[i]*qty[i];
}
else if(no[i]==3)
{
name[i]="12\" Pepperoni Pizza ";
price[i]=20;
tot[i]=price[i]*qty[i];
}
else if(no[i]==4)
{
name[i]="Fries";
price[i]=5;
tot[i]=price[i]*qty[i];
}
else if(no[i]==5)
{
name[i]="Onion Rings";
price[i]=6;
tot[i]=price[i]*qty[i];
}
else if(no[i]==6)
{
name[i]="Pepsi";
price[i]=2;
tot[i]=price[i]*qty[i];
}
else if(no[i]==7)
{
name[i]="Mineral Water";
price[i]=3;
tot[i]=price[i]*qty[i];
}
jum=jum+tot[i];
}
system("cls");
menu();
cout<<"_________________________________"<<endl;
cout<<"Your choice is :"<<endl;
for(int i=0;i<n;i++) //loop for order quantity
{
cout<<""<<qty[i]<<" portion "<<""<<name[i]<<endl;
cout<<"Price/portion ="<<price[i]<<endl;
cout<<"Total Price "<<name[i]<<"="<<tot[i]<<endl;
}
cout<<"We only accept cash payments"<<endl;//I state that my shop only receive cash payments
cout<<"paid : Rm ";
cin>>pay;
cout<<"Do you have a promo code?"<<endl;
cin>>promo;
change=pay-jum;
cout<<"________________________________"<<endl;
cout<<"Your name is:"<<Name<<endl;
cout<<"Phone no is:"<<phone<<endl;
cout<<"Change: Rm"<<change<<endl;
cout<<"Thank you for visiting";
}
else
cout<<"Code your input doesnt exist";
return 0;
}
Step by step
Solved in 4 steps with 1 images