Answer:
See explaination for the program code
Step-by-step explanation:
Program code below;
#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
//function to return name and hours
void getNameAndHoursParked(string &name, int &hours)
{
cout<<"Enter the employee's full name: ";
getline(cin, name);
cout<<"Enter Number of Hours Parked: ";
cin>>hours;
}
//function to check if vehicle is not a Recreational Vehicle
bool isVehicleNotAnRV()
string rv;
cout<<"Is the vehicle is not a Recreational Vehicle: (Y/N)";
cin>>rv;
cin.ignore();
if(rv=="Y"
//function to calculates the parking charges
float getFinalCharge(int hours, bool rv)
{
float charge;
if(hours<=8)
charge = 24;
else
charge = 24 + (hours-8)*3.25;
if(rv) charge += 10;
if(hours<=24 && charge>70) charge = 70;
return charge;
}
//main function
int main()
{
//variable declaration
string name;
int hours;
ofstream ofs;
//open the file
ofs.open("charge-report.txt");
ofs<<left<<setw(15)<<"Full Name"<<setw(15)<<"Parking-Hours";
ofs<<setw(10)<<"Is-RV"<<"Charge"<<endl;
for(int i=0; i<5; i++)
{
//get name and parking hours
getNameAndHoursParked(name, hours);
//check if vehicle is not a Recreational Vehicle
bool rv =isVehicleNotAnRV();
//calculates the parking charges
float charge = getFinalCharge(hours, rv);
ofs<<left<<setw(20)<<name<<setw(10)<<hours;
ofs<<setw(10)<<boolalpha<<rv<<"$"<<charge<<endl;
}
//close the file
ofs.close();
return 0;
}