I'm trying to write a code that calculates a cell phone bill. There are two different services: a regular service that is $10.00 and the first 50 minutes are free and charges over 50 minutes are $.20 per minute and the other a premium service that's $25 and the first 75 day minutes are free and any over that are $.10 and the first 100 night minutes are free and any over that are $.05. This is what I have so far and for some reason I keep getting errors and I'm not sure why. Also, I'm not sure where to calculate the night minutes over 100. Any ideas?

#include <iostream>
using namespace std;

const double rServiceCost = 10.00;
const double rPerMinuteCharge = .20;
const double pServiceCost = 25.00;
const double pDayPerMinuteCharge = .10;
const double pNightPerMinuteCharge = .05;

int main()
{

int minutes;
int dayMinutes;
int nightMinutes;
char serviceCode;
int accountNumber;
double amountDue;

cout << "Enter an account number: ";
cin >> accountNumber;
cout << endl;

cout << "Enter a service code: R or r (regular), P or p (premium): ";
cin >> serviceCode;
cout << endl;

switch (serviceCode)
{
case 'r':
case 'R': cout << "Enter the number of minutes used: ";
          cin >> minutes;
          cout << endl;

          if (minutes > 50)
             amountDue = rServiceCost + ((minutes - 50) * rPerMinuteCharge);
             cout << "Account number = " << accountNumber << endl;
             cout << "Amount Due = $" ,, amountDue << endl;

          else
              amountDue = rServiceCost;
          break;

case 'p':
case 'P': cout << "Enter the number of day minutes used: ";
          cin >> dayMinutes;
          cout << endl;
          cout << "Enter the number of night minutes used: ";
          cin >> nightMinutes;
          cout << endl;

          if dayMinutes > 75
             amountDue = pServiceCost + ((minutes - 75) *   
                                pDayPerMinuteCharge);

          else
              amountDue = pServiceCost;

}
return 0;
}

>cout << "Amount Due = $" ,, amountDue << endl;
You forgot to hit the shift key here, it should be:

cout << "Amount Due = $" << amountDue << endl;
if (minutes > 50)
  amountDue = rServiceCost + ((minutes - 50) * rPerMinuteCharge);
  cout << "Account number = " << accountNumber << endl;
  cout << "Amount Due = $" << amountDue << endl;
else
  amountDue = rServiceCost;

When the body of a conditional or loop is more than one statement, you must surround it in braces to make a compound statement:

if (minutes > 50) {
  amountDue = rServiceCost + ((minutes - 50) * rPerMinuteCharge);
  cout << "Account number = " << accountNumber << endl;
  cout << "Amount Due = $" << amountDue << endl;
}
else
  amountDue = rServiceCost;

>if dayMinutes > 75
Don't forget to put the condition in parentheses:

if (dayMinutes > 75)

>I'm not sure where to calculate the night minutes over 100.
How about right after you calculate the day minutes over 75?

Would I do just another if else statement for the 100 minutes right after the 75? Thanks for all your help too!

>Would I do just another if else statement for the 100 minutes right after the 75?
Why not? Try it and see.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.