### 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.
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768`` `````` #include 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!"<
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:
 ``1234567`` ``````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:
 ``1234`` ``````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:
 ``123456789101112`` ``````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:
 ``123456789101112131415`` ``````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.
Topic archived. No new replies allowed.