A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an additional $0.50 per hour in excess of these initial three hours. The maximum
charge for any given 24 hour period is $10.00. Assume no car parks for longer than 24 hours at a time. Write a program that calculates and prints the total parking charges for the customers
who parked their cars in this garage (at least 4 cars) and the total for each car as well. So, your program should run for a certain number of cars, process how much each car owns
and, in the end, the total amount for the day (considering all cars). All this information should be saved in a file called log_date.txt, where date, is the date when the program was executed (you can collect it from the user)
You need to use at least 2 functions for this program. Remember that hours can have any real number value. The total #of cars and the total hours (displayed to 1 decimal point), and the total charges (rounded to 3 decimal points).
Provide one screenshot – output (screen), input file and output file. (No test cases)
Please use programming language C++




#include <iostream>
#include <iomanip>
#include <fstream>
#include <bits/basic_ios.h>
#define FIXED_FLOAT_1(x)
std::fixed<<std::setprecision(1)<<x
#define FIXED_FLOAT_3(x)
std::fixed<<std::setprecision(3)<<x
using namespace std;
int NoOfCars(string file_name){
ifstream in;
int cars;
float x;
in.open(file_name.c_str());
while(in>>x){
cars++;
}
in.close();
return cars;
}
float CalculateFare(float x){
float fixed_charge=2;
float max_charge=10;
float rent;
if(x<=3){
return fixed_charge;
}
else if(x>16){
return max_charge;
}
else{
rent=fixed_charge+x*0.5;
return rent;
}
}
int main() {
float x,sum=0;
ifstream input;
ofstream output;
string date;
string o_file;
cout<<"Enter the date"<<endl;
getline(cin,date);
o_file="log_"+date+".txt";
input.open("cars.txt");
if (!input) {
cout << "Unable to open file";
// terminate with error
}
// string f="new.txt";
output.open(o_file.c_str());
int i=1;
float total=0;
while (input >> x) {
total=total +x;
output<<"Car "<< i <<" : Hours:
"<<FIXED_FLOAT_1(x)<<" Charges:
"<<FIXED_FLOAT_1(CalculateFare(x))<<endl;
sum=sum+CalculateFare(x);
i++;
}
//total=2.5;
output<<"Total No. of cars:
"<<NoOfCars("cars.txt")<<endl;
output<<"Total Hours:
"<<FIXED_FLOAT_1(total)<<endl;
output<<"Total Charge:
$"<<FIXED_FLOAT_3(sum)<<endl;
input.close();
output.close();
return 0;
}
input file: cars.txt
A parking garage charges a $2.00 minimum fee to park for up to three hours. The...
A parking garage has 5 customers daily. The garage charges a $5.00 minimum fee to park up to two hours. The garage charges an additional $1.00 per hour for each hour (or part of an hour) over two hours. The maximum charge for any given day is $12.00. All cars are gone by midnight. Write a program to calculate and print a summary of the charges for a day. For input the program will read the hours of usage for...
Write a C++ console application that calculates and displays the charges for multiple customers using a parking garage. The parking garage charges a minimum fee of $3.00 to park for up to three hours. The garage charges an additional $0.85 per hour or fraction of an hour for parking over three hours. The maximum charge for any given 24-hour period is $20.00. You may assume that no car parks for longer than 24 hours at a time. Your program will...
Objective: The objective of this lab is to get familiar with the syntax of the Java programming language. This lab is designed to reinforce programming concepts. Instructions: Description of the Problem. A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an additional $0.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is $10.00. Assume that no car parks...
Write a program in C An international airport offers long term parking at the following rates: First 60 minutes is free; 61-80 minutes $4; Each additional 20 minutes $2; And $18 max. per day (24 hours). Write a program longterm_parking.c that calculates and prints the charges for parking at the long term parking garage. 1. The user enters the number of total hours and minutes; the program prints the charge. 2. If the input is invalid, print a message and...
The Bashemin Parking Garage contains a single lane that can hold up to ten cars. Arriving cars enter the garage at the rear and are parked in the empty space nearest to the front. Departing cars exit only from the front. If a customer needs to pick up a car that is not nearest to the exit, then all cars blocking its path are moved out temporarily, the customer's car is driven out, and the other cars are restored in...
Use the description from Parking Ticket Simulator from Chapter 14 as a basis, where you need to create a Car class and Police Officer class, to create a new simulation. Write a simulation program (refer to the Bank Teller example in the PPT) that simulates cars entering a parking lot, paying for parking, and leaving the parking lot. The officer will randomly appear to survey the cars in the lot to ensure that no cars are parked beyond their time...
The CSC326 parking garage contains 2 lanes, each capable of holding up to 10 cars. There is only a single entrace/exit to the garage at one end of the lanes. If a customer arrives to pick up a car which is not nearest the exit, all cars blocking the car's path are moved into the other lane. If more cars still must be moved out of the way, they go into the street. When the customer's car is driven out,...
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...
This is a c++ program. Use the description from Parking Ticket Simulator (listed below) as a basis, where you need to create a Car class and Police Officer class, to create a new simulation. Write a simulation program (refer to the Bank Teller example listed below) that simulates cars entering a parking lot, paying for parking, and leaving the parking lot. The officer will randomly appear to survey the cars in the lot to ensure that no cars are parked...
I need help in C++ . Project 3 – Parking Deck Ticketing System Objectives: Use if, switch, and loop statements to solve a problem. Use input and output statements to model a real world application Incorporate functions to divide the program into smaller segments Instructions: Your task is to write a program that simulates a parking meter within the parking deck. The program will start by reading in the time a car arrives in the parking deck. It will then...