This is a good start.
Line 19: the cost of extra minutes is $0.06, not $0.08.
Since the plans are A, B and C, I'd have the user enter them that way:
1 2 3 4 5 6 7
|
char plan;
cout << " \t\tThe Internet Service Provider Subscription\n";
cout << "A.$19.95 per month. 200 minutes access. Additional Minutes are $0.08\n";
cout << "B.$34.95 per month. 500minutes access. Additional minutes are $0.08\n";
cout << "C.$59.95 per month. Unlimited access.\n";
cout << "Enter your plan: ";
cin >> plan;
|
Then check if their input is valid and exit the program if not:
1 2 3 4
|
if (plan < 'A' || plan > 'C') {
cout << "Plan must be A, B, or C\n";
return 1;
}
|
Next prompt for the number of minutes and input them.
Since you have to compute the cost of all three plans, I'd put the code on lines 31-48 in a function, something like:
1 2 3 4 5 6 7 8 9 10 11 12
|
double cost(double minutes, char plan)
{
double result = 0.0;
switch(plan) {
case 'A':
result = A + (minutes - 200)*2; // NOTE: this is not right
break;
case 'B';
// etc.
}
return result;
}
|
Note that your code to compute the cost isn't right. Hint: what is the cost if the user uses 1 minute?
Once you have this code, make your program print out the cost of the plan they chose - nothing more. Use this version to check the cost() function.
Once you have that working you can write code to print the potential discount. A clean way to do this is something like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
double aCost = cost(minutes, 'A');
double bCost = cost(minutes, 'B');
double cCost = cost(minutes, 'C');
double yourCost = cost(minutes, plan);
cout << "your cost is " << yourCost << ends;
if (aCost < yourCost) {
cout << "You could save " << yourCost-aCost << " with plan A\n";
}
if (bCost < yourCost) {
cout << "You could save " << yourCost-bCost << " with plan B\n";
}
if (cCost < yourCost) {
cout << "You could save " << yourCost-cCost << " with plan C\n";
}
|
This may seem wasteful: your cost is either aCost, bCost or cCost, so why compute it twice? But the code is clean and easy to read.
Finally, add code to input and print out the other stuff - name, address, phone number, month number. Re-read the assignment to see if missed anything.
Good luck.