Your goal is to implement an application that allows employees of a certain perf
ID: 3821599 • Letter: Y
Question
Your goal is to implement an application that allows employees of a certain perfume store toplace customer order.Your application should: get customer information including name, telephone number and address (one field for
each).
ask for the method of payment: Visa, MasterCard, or cash.
ask for customer credit card number if he/she selected Visa or MasterCard.
have four types of perfume (House of Sillage Cherry Garden for $1,150.00, Tom FordNeroli Portofino for $695.00, Cartier Oud & Rose for 380.00, & Viktor&RolfFlowerbomb for $170.95) and five types of accessories (Spinning Perfume Organizer$165.70, Atomizer spray bottle $139.99, Perfume tray $91.90, 2 tiers cosmetic organizer$85.00, and Mist Spray $52.65). Perfumes and accessories prices are shown on thescreen next to each item (see list of menus below). The total price should include tax atrate of 9.75%. (Assume the customers could place one order at a time)
Gifts – Customers get a gift if they select 2 or more distinctive accessories. Selecting 2
accessories: Lipstick; select 3 accessories: Lip pencil; select 4 or more accessories:Eyeshadow. Note: Maximum one gift per order; Customer may not select a gift.
calculate the total price when the user selects "Display Order Confirmation".
When the user selects the “Display Order Confirmation” option:
if input is complete, your application must generate the order confirmation shown below.
if input is incomplete, your application must generate one message, listing all fields
requiring completion.
The user should be able to input data in any order.Use function (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
Cartier Oud & Rose ($33.33)
With the following accessories:
1 Perfume tray ($3.33)2 Mist Spray ($1.11)
Total price: $88.88
Congratulations. You will get the following gift with your order :LipstickSold to:
John DoeTelephone: 12345Address: 123 Nice St.Paid by: Visa number 998877
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
7. Main Menu-------------------------------
1. Visa
2. MasterCard
3. Cash
4. Main Menu
Explanation / Answer
Code:
//Include the needed header files
#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;
}
Sample output:
MENU:
********************************
1. Input Customer Information
2. Main Selection
3. Options
4. Payment method
5. Display Order confirmation
6. Exit
Enter choice:1
Enter name:John Doe
Enter the telephone:12345
Enter the address:123 Nice st
MENU:
********************************
1. Input Customer Information
2. Main Selection
3. Options
4. Payment method
5. Display Order confirmation
6. Exit
Enter choice:2
Perfumes:
1. House of Sillage Cherry Garden $1150.00
2. Tom FordNeroli Portofino for $695.00
3. Cartier Oud & Rose for 380.00
4. Viktor&RolfFlowerbomb for $170.95
6. Main Menu
Ur selection:3
MENU:
********************************
1. Input Customer Information
2. Main Selection
3. Options
4. Payment method
5. Display Order confirmation
6. Exit
Enter choice:3
Accessories:
1. Spinning Perfume Organizer $165.70
2. Atomizer spray bottle $139.99
3. Perfume tray $91.90
4. 2 tiers cosmetic organizer $85.00
5. Mist Spray $52.65
6. Main Menu
Ur selection:3
MENU:
********************************
1. Input Customer Information
2. Main Selection
3. Options
4. Payment method
5. Display Order confirmation
6. Exit
Enter choice:3
Accessories:
1. Spinning Perfume Organizer $165.70
2. Atomizer spray bottle $139.99
3. Perfume tray $91.90
4. 2 tiers cosmetic organizer $85.00
5. Mist Spray $52.65
6. Main Menu
Ur selection:5
MENU:
********************************
1. Input Customer Information
2. Main Selection
3. Options
4. Payment method
5. Display Order confirmation
6. Exit
Enter choice:4
1. Master
2. Visa
3. Cash
Enter option:2
Enter card number:998877
MENU:
********************************
1. Input Customer Information
2. Main Selection
3. Options
4. Payment method
5. Display Order confirmation
6. Exit
Enter choice:5
You have placed an order for
Cartier Oud & Rose
With the following accessories:
Cartier Oud & Rose,Mist Spray
Total price: $575.694
Congratulations. You will get the following gift with your order :Lipstick
Sold to:John Doe
Telephone:12345
Address:123 Nice st
Paid By:Visa 998877
Press any key to continue . . .
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.