Sep 25, 2009 23:22
//This program calculatest the cost of a call from San Francisco to
//Newberg, Oregon. It asks the user to input the start time and lenght
//of the call and calculates the gross and net costs.
#include
#include
using namespace std;
int main ()
{
int startTime, callLength;
float dayGrossCost, tax, hourDiscount, nightGrossCost, netCost;
cout << "Enter start time:" << endl;
cin >> startTime;
cout << "Enter length of call in minutes:" << endl;
cin >> callLength;
/*Any call started at or after 6:00 pm (1800) but before
8:00 am (800.) is discounted 50%.
All calls are subject to a 4% federal tax.
The regular rate is $0.40 per minute.
Any call longer than 60 minutes receives a 15% discount on its cost
(after any other discount is subtracted but before tax is added).*/
//cost of a day call
if (startTime >= 800 || startTime < 1800)
{
dayGrossCost = callLength * 0.40;
hourDiscount = dayGrossCost * .15;
tax = dayGrossCost * 0.04;
cout << "gross cost: $" << fixed << setprecision(2) << dayGrossCost <= 60)
{
netCost = (dayGrossCost - hourDiscount) + tax;
}
cout << "net cost: $" << fixed << setprecision(2) << netCost <= 1800)
{
cout << "call length" << callLength<< endl;
nightGrossCost = (callLength * 0.40)/2.0;
hourDiscount = nightGrossCost * .15;
tax = nightGrossCost * 0.04;
cout << "gross cost: $" << fixed << setprecision(2) << nightGrossCost <= 60)
{
netCost = (nightGrossCost - hourDiscount) + tax;
}
cout << "net cost: $" << fixed << setprecision(2) << netCost <