Posted by: TD November 20, 2006
Login in to Rate this Post:
0
?
can you guys please tell me what in the heck is wrong with this program .... doesn't run
.....i tried to calculate cell phone bill .
#include
#include
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;
}