Here is the assignment:
Mobile Service Provider
A mobile phone service provider has three different subscription packages for its customers:
Package A: For $39.99 per month 450 minutes are provided. Additional minutes are $0.45 per minute.
Package B: For $59.99 per month 900 minutes are provided. Additional minutes are $0.40 per minute.
Package C: For $69.99 per month unlimited minutes provided.
Write a program that calculates a customer’s monthly bill. It should ask which package the customer has purchased and how many minutes were used. It should then display the total amount due.
Input Validation: Be sure the user only selects package A, B, or C.
Mobile Service Provider, Part 2
Modify the Program so that it also displays how much money Package A customers would save if they purchased packages B or C, and how much money Package B customers would save if they purchased Package C. If there would be no savings, no message should be printed.
Mobile Service Provider, Part 3
Months with 30 days have 720 hours, and months with 31 days have 744 hours.
February, with 28 days, has 672 hours. You can calculate the number of minutes in a month by multiplying its number of hours by 60. Enhance the input validation of the Mobile Service Provider program by asking the user for the month (by name), and validating that the number of minutes entered is not more than the maximum for the entire month. Here is a table of the months, their days, and number of hours in each.
The code is not reading what i did for part 2. It jut runs what i did for part one and then terminates. What am i doing wrong?
Also i do not know how to go about part 3.
Can anyone help me fix this?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
//setting everything to 2 decimal places
cout << fixed << setprecision(2);
//declaring variables
char plan, betterplan;
int numMinutes;
string Cmin = "unlimited";
const int Amin = 450, Bmin = 900;
const double AinitialCost = 39.99, BinitialCost = 39.99, CinitialCost = 39.99, AextraPerMin = .45, BextraPerMin = .40;
double cost, save = 0;
int overmin = 0;
//ask user for their plan and have it inputed
cout << "Please enter what plan you have (A, B, or C)." << endl;
cin >> plan;
//This is where im currently haveing trouble--------------------------------------------------------------------------------------------
//check that they entered a valid plan
while ((plan != 'A') && (plan != 'B') && (plan != 'C'));
{
cout << "Your entry was invalid. Please enter A, B or C corrisponding to your plan." << endl;
cin >> plan;
}
//ask user for number of minutes used and have them enter it
cout << "Please enter how many minute you used." << endl;
cin >> numMinutes;
//check that they entered valid number of minutes
while (numMinutes < 0)
{
cout << "Your entry was invalid. Please enter the number of minutes you used, it must be zero or greater." << endl;
cin >> numMinutes;
}
//if they have plan A
if (plan == 'A')
{
//check if they used more minutes then they had
if (numMinutes > Amin)
{
overmin = numMinutes - Amin;
cost = (overmin * AextraPerMin) + AinitialCost;
}
else
{
cost = AinitialCost;
}
//output result
cout << "You chose package " << plan << ", which has a base cost of $" << AinitialCost << " and gives you " << Amin << " minutes." << endl;
//check if they should of choosen a higher plan to save money
if (cost >= BinitialCost && cost < CinitialCost)
{
betterplan = 'B';
save = cost - BinitialCost;
}
else if (cost >= CinitialCost)
{
betterplan = 'C';
save = cost - CinitialCost;
}
}
//if they have plan B
else if (plan == 'B')
{
//check if they used more minutes then they had
if (numMinutes > Amin)
{
overmin = numMinutes - Bmin;
cost = (overmin* BextraPerMin) + BinitialCost;
}
else
{
cost = BinitialCost;
}
//output result
cout << "You chose package " << plan << ", which has a base cost of $" << BinitialCost << " and gives you " << Bmin << " minutes." << endl;
//check if they should of choosen a higher plan to save money
if (cost >= CinitialCost)
{
betterplan = 'C';
save = cost - CinitialCost;
}
}
//if they have plan C
else if (plan == 'C')
{
//output result
cout << "You chose package " << plan << ", which has a base cost of $" << CinitialCost << " and gives you " << Cmin << " minutes." << endl;
cost = CinitialCost;
}
//output result cost
cout << "The total cost will be: " << cost << endl;
//output if they could of saved money
if (save > 0)
{
cout << "By purchaseing plan " << betterplan << " you could of saved $" << save << endl;
}
return 0;
}
| |