C++ programming: Your goal is to implement an application that allows employees
ID: 3911497 • Letter: C
Question
C++ programming:
Your goal is to implement an application that allows employees of a pizzeria to place a customer order.
Your application should:
1. get customer information including name, telephone number, and address (one field for each).
2. ask for the method of payment: Visa, MasterCard, or cash.
3. ask for customer credit card number if he/she selects Visa or MasterCard.
4. have four pizza sizes (Extra Large for $19.89, Large for 16.99, Medium for $12.50, and Small for $9.80) and five toppings (Pepperoni $2.99, Beef $2.45, Mushrooms $2.29, Olives $1.79, Onions $1.20). All prices are for one order. Pizza and topping prices are shown on the screen next to each item (see list of menus below). The total price should include tax at the rate of 9.5%. (Assume the customers could place one order at a time)
5. Gifts - select 2 toppings: Extra topping; select 3 toppings: $3.00 coupon; select 4 or more toppings: Order of cheese sticks. Note: Maximum one gift per order; Customer may not pick a desired gift.
6. calculate the total price when the user selects "Display Order Confirmation".
When the user selects the “Display Order Confirmation” option:
1. if the input is complete, your application must generate an order confirmation shown below.
2. if the input is incomplete, your application must generate one message, listing all the fields requiring completion.
The user should be able to input data in any order.
Use functions (call-by-value only). Do not use global variables. Do not use arrays.
Make sure to test your program completely before submission. Do not forget to add comments. Submit your well-documented C++ program via Canvas.
The order confirmation should look like this:
You have placed an order for
Large pizza ($33.33)
With the following toppings:
Pepperoni ($3.99)
Olives ($2.99)
Total price: $88.88
Sold to: John Doe
Telephone: 12345
Address: 123 Nice St.
Paid by: Visa number 998877
Page 1 of 2
Menus:
1. Input Customer Information
2. Main Selection
3. Options
4. Payment Method
5. Display Order Confirmation
6. Exit
-------------------------------
1. Name
2. Phone Number
3. Address
4. Main Menu
-------------------------------
1. A ($44.44)
2. B ($33.33)
3. C ($22.22)
4. D ($11.11)
5. Main Menu
-------------------------------
1. aa ($1.11)
2. bb ($3.33)
3. cc ($4.44)
4. dd ($5.55)
5. ee ($6.66)
6. Clear all options
7. Main Menu
-------------------------------
1. Visa
2. MasterCard
3. Cash
4. Main Menu
Note: The prices on the menu are not accurate. Use the prices in the project description.
Explanation / Answer
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
//Get selected perfumes cost
float getMainsCost(int sel)
{
float retSum=0;
switch(sel)
{
case 1:
retSum = 1150;
break;
case 2:
retSum = 695;
break;
case 3:
retSum= 380;
break;
case 4:
retSum=170.95;
break;
default:
break;
}
return retSum;
}
//Get selected accessories cost
float getAccessoriesCost(int sel)
{
float retSum=0;
switch(sel)
{
case 1:
retSum = 165.70;
break;
case 2:
retSum = 139.99;
break;
case 3:
retSum= 91.90;
break;
case 4:
retSum=85;
break;
case 5:
retSum = 52.65;
break;
default:
break;
}
return retSum;
}
//Get perfume name
string getPerfumeNames(int sel)
{
string perfumeName="";
switch(sel)
{
case 1:
perfumeName= "House of Sillage Cherry Garden";
break;
case 2:
perfumeName="Tom FOrdNeroli Portfino";
break;
case 3:
perfumeName="Cartier Oud & Rose";
break;
case 4:
perfumeName= "Viktor & Rolfowerbomb";
break;
default:
break;
}
return perfumeName;
}
//get accessory name
string getAccessoriesName(int sel)
{
string acceName="";
switch(sel)
{
case 1:
acceName="Spinning Pefume Organizer";
break;
case 2:
acceName="Atomizer spray bottle";
break;
case 3:
acceName="Perfume tray";
break;
case 4:
acceName="2 tiers cosmetic organizer";break;
case 5:
acceName="Mist Spray";
break;
default:
break;
}
return acceName;
}
//method display the perfume names
void displayPerfumes()
{
cout<<"Perfumes:"<<endl;
cout<<"1. House of Sillage Cherry Garden $1150.00"<<endl;
cout<<"2. Tom FordNeroli Portofino for $695.00"<<endl;
cout<<"3. Cartier Oud & Rose for 380.00"<<endl;
cout<<"4. Viktor&RolfFlowerbomb for $170.95"<<endl;
cout<<"6. Main Menu"<<endl;
}
//method display the accessory names
void displayAccessories()
{
cout<<"Accessories:"<<endl;
cout<<"1. Spinning Perfume Organizer $165.70"<<endl;
cout<<"2. Atomizer spray bottle $139.99"<<endl;
cout<<"3. Perfume tray $91.90"<<endl;
cout<<"4. 2 tiers cosmetic organizer $85.00"<<endl;
cout<<"5. Mist Spray $52.65 "<<endl;
cout<<"6. Main Menu"<<endl;
}
//display the menu
void displayMenu()
{
cout<<"MENU:"<<endl;
cout<<"********************************"<<endl;
cout<<"1. Input Customer Information"<<endl;
cout<<"2. Main Selection"<<endl;
cout<<"3. Options "<<endl;
cout<<"4. Payment method "<<endl;
cout<<"5. Display Order confirmation "<<endl;
cout<<"6. Exit"<<endl;
}
//Get the gift names
string getGiftNames(int sel)
{
string giftName="";
switch(sel)
{
case 2:
giftName="Lipstick";
break;
case 3:
giftName="Lip pencil";
break;
case 4:
giftName="Eye shadow";
break;
default:
giftName="Eye shadow";
break;
}
return giftName;
}
//main
int main()
{
string custName="";
string address="";
string telephoneNum="";
string payment="";
int payMentOption=0;
string cardNumber="";
string accessoriesName="";
string perfumesNames="";
int perCnt=0;
int accesCnt=0;
float totalAmt=0;
int ch=0,sel=0;
int fg=0;
while(fg==0)
{
displayMenu();
cout<<"Enter choice:";
cin>>ch;
switch(ch)
{
//get customer info
case 1:
{
cin.ignore();
cout<<"Enter name:";
getline(cin,custName);
cout<<"Enter the telephone:";
cin>>telephoneNum;
cin.ignore();
cout<<"Enter the address:";
getline(cin,address);
}
break;
//get perfumes
case 2:
{
displayPerfumes();
cout<<"Ur selection:";
cin>>sel;
if(sel!=5)
{
if(perCnt>0)
perfumesNames = perfumesNames+","+getPerfumeNames(sel);
else
perfumesNames = getPerfumeNames(sel);
totalAmt += getMainsCost(sel);
perCnt ++;
}
}
break;
//get accessories selection
case 3:
{
displayAccessories();
cout<<"Ur selection:";
cin>>sel;
if(sel!=6)
{
if(accesCnt>0)
accessoriesName = perfumesNames+","+getAccessoriesName(sel);
else
accessoriesName = getAccessoriesName(sel);
totalAmt += getAccessoriesCost(sel);
accesCnt ++;
}
}
break;
//get payment option
case 4:
{
cout<<"1. Master"<<endl;
cout<<"2. Visa"<<endl;
cout<<"3. Cash"<<endl;
cout<<"Enter option:";
cin>>payMentOption;
if(payMentOption==1 ||payMentOption==2)
{
if(payMentOption==1)
{
payment="Master";
}
else
payment="Visa";
cout<<"Enter card number:";
cin>>cardNumber;
}
else
payment="cash";
}
break;
//display order
case 5:
{
string tpp="";
if(custName.compare("")==0)
tpp= " Require the following details: Customer Name, telephone number, address";
if(payment.compare("")==0)
tpp += "payment mode";
if(perCnt ==0 && accesCnt==0)
tpp += "Place an order";
if(tpp.compare("")==0)
{
cout<< "You have placed an order for ";
cout<<perfumesNames<<endl;
cout<<"With the following accessories:"<<endl;
cout<<accessoriesName<<endl;
totalAmt += totalAmt *0.0975;
cout<<"Total price: $"<<totalAmt<<endl;
if(accesCnt>=2)
{
cout<<"Congratulations. You will get the following gift with your order :";
cout<<getGiftNames(accesCnt)<<endl;
}
cout<<"Sold to:"<<custName<<endl;
cout<<"Telephone:"<<telephoneNum<<endl;
cout<<"Address:"<<address<<endl;
cout<<"Paid By:"<<payment<<" "<<cardNumber<<endl;
fg=1;
}
else
cout<<tpp<<endl;
}
break;
case 6:
exit(0);
break;
default:
break;
}
}
//pause window
system("pause");
//stop
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.