Here's what I have so far and here's my response from my teacher. I'm not exactly sure what or where the problem is. Anyone else see it?

Have you run this project with many different test cases, and does it work? At first glance, it seems to me that the program won't run for certain cases. If, for example, I am a regular customer and I use only 10 minutes, I don't think it will print a bill. A premium customer that uses lots of day and night minutes is going to get two bills printed?? You need to calculate the amount of the bill, then print it. Make sure you've calculated the final amount before you print.

#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 << "Type of service: " << serviceCode << endl;
      cout << "Number of minutes used: " << minutes << 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);
      cout << "Account number = " << accountNumber << endl;
      cout << "Type of service: " << serviceCode << endl;
      cout << "Number of minutes used: " << minutes << endl;
      cout << "Amount Due = $" << amountDue << endl;
    }
    else
      amountDue = pServiceCost;

    if (nightMinutes > 100)
    {
      amountDue = pServiceCost + ((minutes - 100) * pNightPerMinuteCharge);
      cout << "Account number = " << accountNumber << endl;
      cout << "Type of service: " << serviceCode << endl;
      cout << "Number of minutes used: " << minutes << endl;
      cout << "Amount Due = $" << amountDue << endl;
    }
    else
      amountDue = pServiceCost;
    break;

  default: cout << "Invalid service code" << endl;
  }
  return 0;
}

Code tags and consistent formatting added. -Narue

>Anyone else see it?
Yes. Think if it as a word problem. Read your instructor's comments and follow along with the code. You'll see what he's talking about.

This is probably a stupid question, but how do I get the results to output to the screen so I know that the calculations are right?

#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;
          else
              amountDue = rServiceCost + ((minutes - 50) * rPerMinuteCharge);

          cout << "Account number = " << accountNumber << endl;
          cout << "Type of service: " << serviceCode << endl;
          cout << "Number of minutes used: " << minutes << endl;
          cout << "Amount Due = $" << amountDue << endl;
          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;
          else
             amountDue = pServiceCost + ((minutes - 75) * pDayPerMinuteCharge);

          cout << "Account number = " << accountNumber << endl;
          cout << "Type of service: " << serviceCode << endl;
          cout << "Number of minutes used: " << minutes << endl;
          cout << "Amount Due = $" << amountDue << endl;

          if (nightMinutes <= 100)
             amountDue = pServiceCost;

          else
             amountDue = pServiceCost + ((minutes - 100) * pNightPerMinuteCharge);

          cout << "Account number = " << accountNumber << endl;
          cout << "Type of service: " << serviceCode << endl;
          cout << "Number of minutes used: " << minutes << endl;
          cout << "Amount Due = $" << amountDue << endl;
          break;

          default: cout << "Invalid service code" << endl;
          }
          return 0;
}

The results are already printed to the screen. You use cout to print the end result of your calculations, you can also do the same for intermediate results. That's a powerful way of debugging programs.

And please use code tags when you post any length of code. I've added them to your first post, but further posts are up to you.

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.