Write your question here.
Hi
I am new to programming and I am having some difficulty with my latest assignment.
An international phone company has 3 different subscription packages.
A 19.95 per month, 5 hours of talk time, .08 cents per minute overage
B 32.95 per month, 10 hours of talk time, .05 cents per minute of overage
C 45.95 per moth unlimited talk
Write a program that calculates a customers bill. It should prompt for which package (A,B, or C) the customer has.Only if the user indicates that they have package A or B should the program prompt for and get the number of minutes used.
If input is not valid an error message should be displayed and the user given a second chance to enter a value--package types can only be A,B, or C. minutes per month cannot be less than 0
any help would be appreciated I am completely stuck
Thanks
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
|
// Assignment 6, Internet/Phone access
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const double PACKAGE_A = 19.95;
const double PACKAGE_B = 32.95;
const double PACKAGE_C = 45.95;
double minutes;
double total;
double overage;
char package;
cout << fixed << showpoint << setprecision(2);
cout << "Please indicate which package was purchased by entering A, B, or C " << endl;
cin >> package;
if (package == 'A')
{
cout << "How many minutes were used?" << endl;
cin >> minutes;
{
if (minutes > 300)
{
overage = (minutes - 300) * .08;
total = overage + PACKAGE_A;
cout << "Your toatal is $ " << total << endl;
}
else
cout << "Your toatal is $ " << PACKAGE_A << endl;
}
}
if (package == 'B')
cout << "How many minutes were used?" << endl;
cin >> minutes;
{
if (minutes > 600)
{
overage = (minutes - 600) * .05;
total = overage + PACKAGE_B;
cout << "Your toatal is $ " << total << endl;
}
else
{
cout << "Your toatal is $ " << PACKAGE_B << endl;
}
}
if ( package == 'C')
{
cout << "Your toatal is $ " << PACKAGE_C << endl;
}
else
cout << "Invalid Entry" << endl;
return 0;
}
|