Question

Assignment: My friend, Cary Parker, owns a small parking garage downtown. She wants you to write...

Assignment:

My friend, Cary Parker, owns a small parking garage downtown. She wants you to write a program to help her calculate the parking charge at the payment booth.

The price to park in the lot is $5.50 per hour, plus city parking tax. However, partial hours (even one minute into an additional hour) are charged at the full hour’s rate. For example, if you park for exactly 60 minutes, or less, you will pay $5.50 plus tax, but if you park for 61 minutes you will pay $11.00 plus tax. At 121 minutes you will pay $16.50 plus tax, and so on. The city parking tax is calculated at 9.5% of the parking fee.

Cary operates her parking lot using a 24 hour clock, so, for example, half past midnight is 00:30, 10:30 am is 10:30, and 10:30pm is 22:30. The garage closes at midnight, so you don't have to worry about entering the garage one day and leaving the next.

Sample Dialog

Welcome to Cary Parker’s Garage

Time of Entry (Hour): 11

Time of Entry (Minute): 35

Time of Exit (Hour): 14

Time of Exit (Minute): 25

You parked for 3 hours.

The parking fee is $16.50

The city tax is $1.57

Your total charge is $18.07

Thank you for using Cary Parker’s Garage

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

#include <iostream>
#include <iomanip>
#include <ctime>
#include <cstdlib>
using namespace std;

int main()
{
   //Declaring constants
   const double CHARGES_PER_HR=5.50;
   const double TAX_RATE=9.5;
  
  
   //setting the precision to two decimal places
   std::cout << std::setprecision(2) << std::fixed;
     
   //Declaring variables
int entryHours,exitHours,entryMins,exitMins,diffhrs,diffmins;
double parkingCharges,taxRate,totalCharge=0;
cout<<"Welcome to Cary Parker’s Garage"<<endl;

//Getting the input entered by the user
cout<<"Time of Entry (Hour): ";
cin>>entryHours;
cout<<"Time of Entry (Minute): ";
cin>>entryMins;
cout<<"Time of Exit (Hour): ";
cin>>exitHours;
cout<<"Time of Exit (Minute): ";
cin>>exitMins;

//Performing calculations
diffhrs=(exitHours-entryHours);
diffmins=(exitMins-entryMins);
  
if(diffmins<0)
{
   parkingCharges=diffhrs*CHARGES_PER_HR;

}
else if(diffmins>0)
{
   parkingCharges=(diffhrs+1)*CHARGES_PER_HR;
   diffhrs++;

}
taxRate=parkingCharges*(9.5/100);
  
//Displaying the output
   cout<<"You parked for "<<diffhrs<<" hours"<<endl;
   cout<<"The parking fee is $"<<parkingCharges<<endl;
   cout<<"The city tax is $"<<taxRate<<endl;
   totalCharge=parkingCharges+taxRate;
   cout<<"Your total charge is $"<<totalCharge<<endl;
   cout<<"Thank you for using Cary Parker's Garage"<<endl;

return 0;
}

___________________________

Output:

_______________Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
Assignment: My friend, Cary Parker, owns a small parking garage downtown. She wants you to write...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT