Task 1 Solution
source code
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int choice, phone_type, itemprice,sim_choice,simprice,case_choice,charger_choice,caseprice,chargerprice;
string itemdesc, itemcode,simdesc,simcode,casedesc,casecode,chargerdesc,chargercode;
//for phone
string phone_code[6] = {"BPCM", "BPSH", "RPSS", "RPLL", "YPLS", "YPLL"};
string phone_desc[6] = {"Compact", "Clam Shell", "Robo phone-5-inch screen and 64gb memory", "Robo phone-6-inch screen and 256gb memory", "Y-phone sandard-6-inch screen and 64gb memory", "Y-phone Delux-6-inch screen and 64gb memory"};
float phone_price[6] = {29.99, 49.99, 199.99, 499.99, 549.99, 649.99};
//for tablet
int tablet_type,t_itemprice;
string t_itemdesc,t_itemcode;
string tablet_code[4] = {"RTMS", "RTLM", "YTLM", "YTLL"};
string tablet_desc[4] = {"Robo-tab 8 inch screen 64gb memory", "Robo-tab 10 inch screen 128gb memory", "Y-Tab sandard-10-inch screen and 128gb memory", "Y-TAb Delux-10-inch screen and 256gb memory"};
float tablet_price[4] = {149.99, 299.99, 499.99, 599.99};
string sim_code[2] = {"SMNO", "SMPG"};
string sim_desc[2] = {"Sim free(no sim card purchase)", "pay as you go(sim card purchase)"};
float sim_price[2] = {0.00, 9.99};
string case_code[2] = {"CSST", "CSLX"};
string case_desc[2] = {"Standard", "Luxary"};
float case_price[2] = {0.00, 50.00};
string charger_code[2] = {"CGCR", "CGHM"};
string charger_desc[2] = {"Car", "Home"};
float charger_price[2] = {19.99, 15.99};
again:
cout << "\nWhat do you want to buy press 1: for phone and press 2 for tablet" << endl;
cin >> choice;
phoneagain:
if (choice == 1)
{
cout << "Press 1 for phone."
<< " Code:" << phone_code[0] << " "
<< " Description :" << phone_desc[0] << " "
<< " Price: $" << phone_price[0] << endl;
cout << "Press 2 for phone."
<< " Code:" << phone_code[1] << " "
<< " Description :" << phone_desc[1] << " "
<< " Price: $" << phone_price[1] << endl;
cout << "Press 3 for phone."
<< " Code:" << phone_code[2] << " "
<< " Description :" << phone_desc[2] << " "
<< " Price: $" << phone_price[2] << endl;
cout << "Press 4 for phone."
<< " Code:" << phone_code[3] << " "
<< " Description :" << phone_desc[3] << " "
<< " Price: $" << phone_price[3] << endl;
cout << "Press 5 for phone."
<< " Code:" << phone_code[4] << " "
<< " Description :" << phone_desc[4] << " "
<< " Price: $" << phone_price[4] << endl;
cout << "Press 6 for phone."
<< " Code:" << phone_code[5] << " "
<< " Description :" << phone_desc[5] << " "
<< " Price: $" << phone_price[5] << endl;
cout << "what kind of phone do you want(enter the number)" << endl;
cin >> phone_type;
if (phone_type == 1 || phone_type == 2 || phone_type == 3 || phone_type == 4 || phone_type == 5 || phone_type == 6)
{
itemcode = phone_code[phone_type - 1];
itemdesc = phone_desc[phone_type - 1];
itemprice = phone_price[phone_type - 1];
cout << "\nThe phone that you want has code: " << itemcode << endl;
cout << "The phone that you want has description: " << itemdesc << endl;
cout << "The phone that you want has price: $ " << itemprice << endl;
}
else{
cout<<"\nPlease Enter correct!!!!!"<<endl;
goto phoneagain;
}
}
else if (choice==2)
{
tabletagain:
/* code */
cout << "Press 1 for tablet"
<< " Code:" << tablet_code[0] << " "
<< " Description :" << tablet_desc[0] << " "
<< " Price: $" << tablet_price[0] << endl;
cout << "Press 2 for tablet"
<< " Code:" << tablet_code[1] << " "
<< " Description :" << tablet_desc[1] << " "
<< " Price: $" << tablet_price[1] << endl;
cout << "Press 3 for tablet"
<< " Code:" << tablet_code[2] << " "
<< " Description :" << tablet_desc[2] << " "
<< " Price: $" << tablet_price[2] << endl;
cout << "Press 4 for tablet"
<< " Code:" << tablet_code[3] << " "
<< " Description :" << tablet_desc[3] << " "
<< " Price: $" << tablet_price[3] << endl;
cout << "what kind of tablet do you want(enter the number)" << endl;
cin >> tablet_type;
if (tablet_type == 1 || tablet_type == 2 || tablet_type == 3 || tablet_type == 4)
{
t_itemcode = tablet_code[tablet_type - 1];
t_itemdesc = tablet_desc[tablet_type - 1];
t_itemprice = tablet_price[tablet_type - 1];
cout << "\nThe tablet that you want has code: " << t_itemcode << endl;
cout << "The tablet that you want has description: " << t_itemdesc << endl;
cout << "The tablet that you want has price: $ " << t_itemprice << endl;
}
else{
cout<<"\nPlease Enter correct!!!!!"<<endl;
goto tabletagain;
}
}
else{
cout<<"!!!Please enter correct number"<<endl;
goto again;
}
//for sims
simagain:
cout << "\nPress 1 for sim:"
<< " Code:" << sim_code[0] << " "
<< " Description :" << sim_desc[0] << " "
<< " Price: $" << sim_price[0] << endl;
cout << "Press 2 for sim:"
<< " Code:" << sim_code[1] << " "
<< " Description :" << sim_desc[1] << " "
<< " Price: $" << sim_price[1] << endl;
cin>>sim_choice;
if (sim_choice == 1 || sim_choice == 2 )
{
simcode = sim_code[sim_choice - 1];
simdesc = sim_desc[sim_choice - 1];
simprice = sim_price[sim_choice - 1];
cout << "\nThe sim that you want has code: " << simcode << endl;
cout << "The sim that you want has description: " << simdesc << endl;
cout << "The sim that you want has price: $ " << simprice << endl;
}
else{
cout<<"\nPlease Enter correct!!!!!"<<endl;
goto simagain;
}
caseagain:
cout << "\nPress 1 for case:"
<< " Code:" << case_code[0] << " "
<< " Description :" << case_desc[0] << " "
<< " Price: $" << case_price[0] << endl;
cout << "Press 2 for case:"
<< " Code:" << case_code[1] << " "
<< " Description :" << case_desc[1] << " "
<< " Price: $" << case_price[1] << endl;
cin>>case_choice;
if (case_choice == 1 || case_choice == 2 )
{
casecode = case_code[case_choice - 1];
casedesc = case_desc[case_choice - 1];
caseprice = case_price[case_choice - 1];
cout << "\nThe case that you want has code: " << casecode << endl;
cout << "The case that you want has description: " << casedesc << endl;
cout << "The case that you want has price: $ " << caseprice << endl;
}
else{
cout<<"\nPlease Enter correct!!!!!"<<endl;
goto caseagain;
}
chargeragain:
cout << "\nPress 1 for charger:"
<< " Code:" << charger_code[0] << " "
<< " Description :" << charger_desc[0] << " "
<< " Price: $" << charger_price[0] << endl;
cout << "Press 2 for charger:"
<< " Code:" << charger_code[1] << " "
<< " Description :" << charger_desc[1] << " "
<< " Price: $" << charger_price[1] << endl;
cin>>charger_choice;
if (charger_choice == 1 || charger_choice == 2 )
{
chargercode = charger_code[charger_choice - 1];
chargerdesc = charger_desc[charger_choice - 1];
chargerprice = charger_price[charger_choice - 1];
cout << "\nThe charger that you want has code: " << chargercode << endl;
cout << "The charger that you want has description: " << chargerdesc << endl;
cout << "The charger that you want has price: $ " << chargerprice << endl;
}
else{
cout<<"\nPlease Enter correct!!!!!"<<endl;
goto chargeragain;
}
cout<<"\n*************************************************"<<endl;
if (choice==1)
{
/* code */
cout<<"\n------------------------------------The item Purchased are-----------------------------------"<<endl;
cout<<"Phone: "<<itemcode<<" "<<itemdesc<<"\nSim: "<<simcode<<" "<<simdesc<<"\nCase: "<<casecode<<" "<<casedesc<<"\nCharger: "<<chargercode<<" "<<chargerdesc<<endl;
cout<<"\n****The price of item that are purchased****"<<endl;
int price=itemprice+simprice+caseprice+chargerprice;
cout<<"\nThe total price of item: $ "<<price<<endl;
}
else{
cout<<"\n------------------------------------The item Purchased are-----------------------------------"<<endl;
cout<<"Tablet: "<<t_itemcode<<" "<<t_itemdesc<<"\nSim: "<<simcode<<" "<<simdesc<<"\nCase: "<<casecode<<" "<<casedesc<<"\nCharger: "<<chargercode<<" "<<chargerdesc<<endl;
cout<<"\n****The price of item that are purchased****"<<endl;
int price=t_itemprice+simprice+caseprice+chargerprice;
cout<<"\nThe total price of item: $ "<<price<<endl;
}
return 0;
}
Output
0 Comments