PART A: (Online Cell Phone Plan Subscription Program) Options available for Purc
ID: 3888307 • Letter: P
Question
PART A: (Online Cell Phone Plan Subscription Program)
Options available for Purchasing Cell Phone:
OPTION
CATEGORY
1
Samsung Galaxy S8 ($30/month)
2
Samsung Galaxy S8 Plus ($35/month)
3
LG G6 ($20/moth)
4
Apple iPhone 7 ($25.99/month)
5
Apple iPhone 7 Plus ($49.99/month)
-1
Continue to Phone Plan Selection
Write a C++ program for Mobile Plus Communications (MPC) Mobile Communications Company that asks customers to select from the list of smart phones in the table above. The Menu will be presented to customers upon entering the MPC.com website. For now, this program will only run on a desktop computer. After all the phones are selected, the customer must then select a Plan from the following Phone Plan Option List:
Phone Plans available after selecting phones from the menu above:
OPTION
SELECTION
Plan A
4 phone Lines or More - $50/Line per month, otherwise a flat fee of $300/month
Plan B
Less than 4 Lines - $70/Line per month, otherwise $50/Line per month
Plan C
Plan with Tablet Line (Any number of Lines) $60/Line per month
If the customer enters any option that is not in the tables above, the program should display “Invalid Option Selected”. You must use the switch statement in your program to solve this problem.
The program should calculate the total cost of the purchase based on the user’s selections and then provide the following output summary.
· Number of Phones Purchased for each type of phone
· Plan Selected
· Number of phone lines activated
· Total Cost
The following is a sample output
********************************
1. Samsung Galaxy S8 ($30/month)
2. Samsung Galaxy S8 Plus ($35/month)
3. LG G6 ($20/moth)
4. Apple iPhone 7 ($25.99/month)
5. Apple iPhone 7 Plus ($49.99/month)
9. Exit
Enter your phone selection (1-5: 9 to exit): 1
Enter the number of phones for this selection: 3
*********************************
1. Samsung Galaxy S8 ($30/month)
2. Samsung Galaxy S8 Plus ($35/month)
3. LG G6 ($20/moth)
4. Apple iPhone 7 ($25.99/month)
5. Apple iPhone 7 Plus ($49.99/month)
9. Exit
Enter your phone selection (1-5: 9 to exit): 2
Enter the number of phones for this selection: 3
*********************************
1. Samsung Galaxy S8 ($30/month)
2. Samsung Galaxy S8 Plus ($35/month)
3. LG G6 ($20/moth)
4. Apple iPhone 7 ($25.99/month)
5. Apple iPhone 7 Plus ($49.99/month)
9. Exit
Enter your phone selection (1-5: 9 to exit): 3
Enter the number of phones for this selection: 1
*********************************
1. Samsung Galaxy S8 ($30/month)
2. Samsung Galaxy S8 Plus ($35/month)
3. LG G6 ($20/moth)
4. Apple iPhone 7 ($25.99/month)
5. Apple iPhone 7 Plus ($49.99/month)
9. Exit
Enter your phone selection (1-5: 9 to exit): 4
Enter the number of phones for this selection: 2
*********************************
1. Samsung Galaxy S8 ($30/month)
2. Samsung Galaxy S8 Plus ($35/month)
3. LG G6 ($20/moth)
4. Apple iPhone 7 ($25.99/month)
5. Apple iPhone 7 Plus ($49.99/month)
9. Exit
Enter your phone selection (1-5: 9 to exit): 5
Enter the number of phones for this selection: 1
*********************************
1. Samsung Galaxy S8 ($30/month)
2. Samsung Galaxy S8 Plus ($35/month)
3. LG G6 ($20/moth)
4. Apple iPhone 7 ($25.99/month)
5. Apple iPhone 7 Plus ($49.99/month)
9. Exit
Enter your phone selection (1-5: 9 to exit): 9
***************PLAN SELECTION******************
Which plan would you like to participate in?
A. 4 phone Lines or More - $50/Line, otherwise flat fee of $300/month
B. Less than 4 Lines - $70/Line, otherwise $50/Line per month
C. Plan with Tablet Line (Any number of Lines) $60/Line
Enter your Phone Plan (A, B or C): A
How many lines do you want activated? 6
*************** SUMMARY **************
Items Ordered:
Samsung Galaxy S8 ($30/month): 3
Samsung Galaxy S8 Plus ($35/month): 3
LG G6 ($20/moth): 1
Apple iPhone 7 ($25.99/month): 2
Apple iPhone 7 Plus ($49.99/month): 1
You have selected Plan A
The number of phone lines activated is 6
Your total cost is $616.97 per month
Press any key to continue . . .
OPTION
CATEGORY
1
Samsung Galaxy S8 ($30/month)
2
Samsung Galaxy S8 Plus ($35/month)
3
LG G6 ($20/moth)
4
Apple iPhone 7 ($25.99/month)
5
Apple iPhone 7 Plus ($49.99/month)
-1
Continue to Phone Plan Selection
Explanation / Answer
Given below is the C++ program for the question with output. Hope the answer helps. If it did, please don't forget to rate the answer. Thank you very much.
Note: In the question, the table shows -1 to be used as an option "Continue to select plan" , but in the sample output shown at the end of question, 9 is being used for exiting phone selection and continuing to plan selection. So I have used 9 for that.
#include <iostream>
using namespace std;
int main()
{
int numLines = 0, activatedLines = 0;
int samsung_s8 = 0, samsung_s8plus = 0;
int lg_g6 =0;
int apple_iph7 =0, apple_iph7plus = 0;
double total_cost = 0;
char plan;
int choice = 0, n;
while(choice != 9)
{
cout<<"********************************" << endl;
cout<<"1. Samsung Galaxy S8 ($30/month)"<<endl;
cout<<"2. Samsung Galaxy S8 Plus ($35/month)"<<endl;
cout<<"3. LG G6 ($20/month)"<<endl;
cout<<"4. Apple iPhone 7 ($25.99/month)"<<endl;
cout<<"5. Apple iPhone 7 Plus ($49.99/month)"<<endl;
cout<<"9. Continue to Phone Plan selection"<<endl;
cout<<" Enter your selection(1-5: 9 to exit): ";
cin >> choice;
if(choice != 9) //if not continue to plan selection
{
cout<<"Enter the number of phones for this selection: ";
cin>>n;
numLines += n; //increase the number of lines
}
//depending on phone selection , add the cost for n phones
//also increase counter of that phone type
switch(choice)
{
case 1:
samsung_s8+=n;
total_cost += n * 30;
break;
case 2:
samsung_s8plus+=n;
total_cost += n * 35;
break;
case 3:
lg_g6 += n;
total_cost += n * 20;
break;
case 4:
apple_iph7+=n;
total_cost += n * 25.99;
break;
case 5:
apple_iph7plus+=n;
total_cost += n * 49.99;
break;
case 9:
break;
default:
cout<<"Invalid option selected ! "<<endl;
}
cout<<endl;
}
cout << " ***************PLAN SELECTION******************" << endl;
cout << "Which plan would you like to participate in? " << endl;
cout << "A. 4 phone Lines or More - $50/Line, otherwise flat fee of $300/month " <<endl;
cout << "B. Less than 4 Lines - $70/Line, otherwise $50/Line per month" << endl;
cout << "C. Plan with Tablet Line (Any number of Lines) $60/Line" << endl;
cout << "Enter your Phone Plan (A, B or C): ";
cin >> plan;
cout << "How many lines do you want activated? ";
cin >> activatedLines;
switch(plan)
{
case 'A':
if(numLines >= 4)
total_cost += activatedLines * 50; //50 per line if 4 or more lines
else
total_cost += 300; //flat 300
break;
case 'B':
if(numLines < 4)
total_cost += activatedLines * 70; //70/line if less than 4
else
total_cost += activatedLines * 50;
break;
case 'C':
total_cost += activatedLines * 60;
break;
}
cout <<" *************** SUMMARY **************"<<endl<<endl;
cout<<" Items ordered:"<<endl;
cout<<"1. Samsung Galaxy S8 ($30/month): "<< samsung_s8 <<endl;
cout<<"2. Samsung Galaxy S8 Plus ($35/month): "<< samsung_s8plus << endl;
cout<<"3. LG G6 ($20/month): "<< lg_g6 << endl;
cout<<"4. Apple iPhone 7 ($25.99/month): "<< apple_iph7 <<endl;
cout<<"5. Apple iPhone 7 Plus ($49.99): "<<apple_iph7plus<<endl<<endl;
cout<<"You have selected Plan " << plan <<endl;
cout<<"The number of phone lines activated is " << activatedLines <<endl;
cout<<"Your total cost is $"<<total_cost<< " per month" << endl<<endl;
}
output
********************************
1. Samsung Galaxy S8 ($30/month)
2. Samsung Galaxy S8 Plus ($35/month)
3. LG G6 ($20/month)
4. Apple iPhone 7 ($25.99/month)
5. Apple iPhone 7 Plus ($49.99/month)
9. Continue to Phone Plan selection
Enter your selection(1-5: 9 to exit): 1
Enter the number of phones for this selection: 3
********************************
1. Samsung Galaxy S8 ($30/month)
2. Samsung Galaxy S8 Plus ($35/month)
3. LG G6 ($20/month)
4. Apple iPhone 7 ($25.99/month)
5. Apple iPhone 7 Plus ($49.99/month)
9. Continue to Phone Plan selection
Enter your selection(1-5: 9 to exit): 2
Enter the number of phones for this selection: 3
********************************
1. Samsung Galaxy S8 ($30/month)
2. Samsung Galaxy S8 Plus ($35/month)
3. LG G6 ($20/month)
4. Apple iPhone 7 ($25.99/month)
5. Apple iPhone 7 Plus ($49.99/month)
9. Continue to Phone Plan selection
Enter your selection(1-5: 9 to exit): 3
Enter the number of phones for this selection: 1
********************************
1. Samsung Galaxy S8 ($30/month)
2. Samsung Galaxy S8 Plus ($35/month)
3. LG G6 ($20/month)
4. Apple iPhone 7 ($25.99/month)
5. Apple iPhone 7 Plus ($49.99/month)
9. Continue to Phone Plan selection
Enter your selection(1-5: 9 to exit): 4
Enter the number of phones for this selection: 2
********************************
1. Samsung Galaxy S8 ($30/month)
2. Samsung Galaxy S8 Plus ($35/month)
3. LG G6 ($20/month)
4. Apple iPhone 7 ($25.99/month)
5. Apple iPhone 7 Plus ($49.99/month)
9. Continue to Phone Plan selection
Enter your selection(1-5: 9 to exit): 5
Enter the number of phones for this selection: 1
********************************
1. Samsung Galaxy S8 ($30/month)
2. Samsung Galaxy S8 Plus ($35/month)
3. LG G6 ($20/month)
4. Apple iPhone 7 ($25.99/month)
5. Apple iPhone 7 Plus ($49.99/month)
9. Continue to Phone Plan selection
Enter your selection(1-5: 9 to exit): 9
***************PLAN SELECTION******************
Which plan would you like to participate in?
A. 4 phone Lines or More - $50/Line, otherwise flat fee of $300/month
B. Less than 4 Lines - $70/Line, otherwise $50/Line per month
C. Plan with Tablet Line (Any number of Lines) $60/Line
Enter your Phone Plan (A, B or C): A
How many lines do you want activated? 6
*************** SUMMARY **************
Items ordered:
1. Samsung Galaxy S8 ($30/month): 3
2. Samsung Galaxy S8 Plus ($35/month): 3
3. LG G6 ($20/month): 1
4. Apple iPhone 7 ($25.99/month): 2
5. Apple iPhone 7 Plus ($49.99): 1
You have selected Plan A
The number of phone lines activated is 6
Your total cost is $616.97 per month
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.