can someone help me with my assignment?

An international mobile phone company has three different rate plans for its customers:
A) For $19.95 per month 200 minutes of call time are provided. Additional usage costs $0.08 per minute.
B)For $34.95 per month 500 minutes of call time are provided. Additional usage costs $0.06 per minute.
C)For $59.95 per month unlimited call time is provided

Write a program that calculates a customer’s monthly bill. It should input customer name, mailing address, telephone number, the month, which package the customer has purchased, and how many minutes were used during the month. It should then create a bill that includes the input information and the total amount due. As an incentive from the mobile phone company to its customers, the program should also display 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.

Is it good? or am I missing anything ? Can someone help me ?

Input Validation: Be sure the user only selects package A, B, or C.
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
  #include <iostream>
using namespace std;

int main ()
{
int choice;
int hours;
double total;

double A = 19.95;
double B = 34.95;
double C = 59.95;
double D = 0.08;
double E = 0.06;

//Display
cout << " \t\tThe Internet Service Provider Subscription\n";
cout << "1. A.$19.95 per month. 200 minutes access. Additional Minutes are $0.08\n";
cout << "2. B.$34.95 per month. 500minutes access. Additional minutes are $0.08\n";
cout << "3. C.$59.95 per month. Unlimited access.\n";
cout << "Enter your choice: ";
cin >> choice;

if (choice >=1 && choice <=3)
{
cout << "How many hours would you access: ";
cin >> hours;



switch (choice)
{
case 1:
{
total = A + (minutes - 200)*2;
break;
}
case 2: 
{
total = B + (minutes - 500)*1;
break;
}

case 3: 
{
total = C;
break;
}

default:
cout<<"You enter a wrong value!"<<endl;
cout << "The valid choices are 1 through 3. \n Run the program again.";

}

cout << "The total charges is equal to:$ "<<total<<endl;
}



else if (choice !=3)

{
cout << "The valid choices are 1 through 3. \n Run the program again.";
}
return 0;
}
Last edited on
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.
I had this same assignment at SRJC, If you're studying there then I suggest you read Dave's requirements as far as Commenting, he ends up taking a huge chunk (like 20%) off your grade if things aren't commented out the way he wants. He would also dock you points for your variable's names not being descriptive enough.
Further he will take more off for not using spacing...
I haven't checked your code past those details, I just wanted to give you a heads up if you're his student. I ended up using up more time commenting for the program than I took actually writing the code in the first place.
Last edited on
thank you guys for your help. and no im not going to SRJC.

plus dhayden i didnt get the last part and the part before that.
Registered users can post here. Sign in or register to post.