Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For C + + A mobile phone service provider has three different data plans for its customers: Plan A - For $ 3 9 .
For C
A mobile phone service provider has three different data plans for its customers:
Plan A For $ per month, gigabytes are provided. Additional usage costs $ per gigabyte.
Plan B For $ per month, gigabytes are provided. Additional usage cost $ per gigabyte.
Plan C For $ per month, unlimited data is provided.
Write a program that calculates a customer's monthly bill. It should input the customer name, which plan was purchased, and how many gigabytes were used. It should then create a bill that includes the input information and the total amount due. It should also display how much money plan A customers would save if they purchased plan B or C and how much money plan B customers would save if they purchased plan C If there would be no savings, no message should be printed. Wherever possible, use named constants instead of numbers, this part is important.
This is what I have and it's not doing the savings correctly. What am I missing?
#include
#include
using namespace std;
Constants
const double planAprice ;
const int planAincluded ;
const double planAextra ;
const double planBprice ;
const int planBincluded ;
const double planBextra ;
const double planCprice ;
To calculate total bill for each plan
void calculateBillchar plan, double usedData
double totalCost, savingsB, savingsC;
switch plan
case A:
totalCost planAprice;
if usedData planAincluded
totalCost usedData planAincluded planAextra;
savingsB totalCost planBprice planBprice totalCost : ;
savingsC totalCost planCprice planCprice totalCost : ;
break;
case B:
totalCost planBprice;
if usedData planBincluded
totalCost usedData planBincluded planBextra;
savingsB ;
savingsC totalCost planCprice planCprice totalCost : ;
break;
case C:
totalCost planCprice;
savingsB ;
savingsC ;
break;
default:
cout "Invalid plan choice." endl;
return;
To display the bill
cout fixed setprecision;
cout "Total Amount Due: $ totalCost endl;
To display the savings for Plan A and Plan B customers
if plan A
if totalCost planBprice && savingsB
cout "Savings if you had purchased Plan B: $ savingsB endl;
if totalCost planCprice && savingsC
cout "Savings if you had purchased Plan C: $ savingsC endl;
else if plan B
if totalCost planCprice && savingsC
cout "Savings if you had purchased Plan C: $ savingsC endl;
int main
string customerName;
char planPurchased;
double gigabytesUsed;
cout "Enter customer name: ;
cin customerName;
cout "Enter plan purchased A B or C: ;
cin planPurchased;
cout "Enter the number of gigabytes used: ;
cin gigabytesUsed;
cout endl;
cout "Your Phone Bill" endl;
cout "Customer Name: customerName endl;
cout "Plan Purchased: planPurchased endl;
cout "Gigabytes Used: gigabytesUsed endl;
calculateBilltoupperplanPurchased gigabytesUsed;
return ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started