Need help with finding savings in different plans.
Feb 25, 2020 at 10:35am UTC
My assignment is to compare 3 different voice plans and ask a customer which plan they would like to choose along with how many minutes they use.
Plan A: 450 minutes for $39.99 (.45/minute for each additional minute used.)
Plan B: 900 minutes for $59.99 (.40/minute for each additional minute used.)
Plan C: Unlimited minutes for $69.99.
After finding the values, I must then display a message telling the customer how much they would save with a different plan.
EX: Customer chooses Plan A but uses 501 minutes. The total would come out to $62.94.
I would then have to display that the customer would save $2.95 if they switched to plan B from plan A. I've already done the rest but can't seem to manage to find a way to have the savings displayed correctly.
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
#include <iostream>
using namespace std;
int main() {
// variables
double package_a_price = 39.99;
double package_a_price1;
double package_b_price = 59.99;
double package_b_price1;
double package_c_price = 69.99;
double package_a_minutes = 450;
double package_b_minutes = 900;
double package_a_additional_charges = .45;
double package_b_additional_charges = .40;
char plan_choice;
// Display
cout << "The mobile phone service provider offers the following voice plans:\n" << endl;
cout << "Package A: 450 minutes for 39.99. (.45/minute for each additional minute.)" << endl;
cout << "Package B: 900 minutes for 59.99. (.40/minute for each additional minute.)" << endl;
cout << "Package C: Unlimited Minutes for 69.99.\n" << endl;
cout << "Enter which voice plan the customer subscribes to: " << endl;
cin >> plan_choice;
cout << endl;
// Calculate User's Plan
switch (plan_choice)
{
int mins_used;
float total_charges;
case 'a' :
case 'A' :
case 'b' :
case 'B' :
case 'c' :
case 'C' :
cout << "Enter the total number of minutes used during the month: " ;
cin >> mins_used ;
cout << endl;
if (mins_used < 0 || mins_used > 44640)
{
cout << "That is not a valid amount for the minutes." << endl;
}
else
{
cout << "The amount due for the month is $" ;
if (plan_choice == 'a' || plan_choice == 'A' )
{
total_charges = mins_used > package_a_minutes
? package_a_price + ((mins_used - package_a_minutes) * package_a_additional_charges)
: package_a_price;
}
else if (plan_choice == 'b' || plan_choice == 'B' )
{
total_charges = mins_used > package_b_minutes
? package_b_price + ((mins_used - package_b_minutes) * package_b_additional_charges)
: package_b_price;
}
else if (plan_choice == 'c' || plan_choice == 'C' )
{
total_charges = package_c_price;
}
cout << total_charges << endl;
}
break ;
default :
cout << "The voice plan entered is invalid." << endl;
break ;
}
return 0;
};
Feb 25, 2020 at 12:47pm UTC
1 2
if total_charges_plan_a < total_charges_plan_b:
print("you'll save " , total_charges_plan_b - total_charges_plan_a, " for being on plan A"
Feb 25, 2020 at 11:58pm UTC
Thank you!
Topic archived. No new replies allowed.