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