Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program (C++) that calculates and displays the total travel expenses of

ID: 3917697 • Letter: W

Question

Write a program (C++) that calculates and displays the total travel expenses of a businessperson on a trip. The program should have functions that ask for and return the following:

-The total number of days spent on the trip

-The time of departure on the first day of the trip, and the time of arrival back home on the last day of the trip

-The amount of any round-trip airfare

-The amount of any car rentals

-Miles driven, if a private vehicle was used. Calculate the vehicle expense as $0.27 per mile driven.

-Parking fees (The company allows up to $6 per day. Anything in excess of this must be paid by the employee).

-Taxi fees, if a taxi was used anytime during the trip (the company allows up to $10 per day, for each day a taxi was used. Anything in excess of this must be paid by the employee).

-Conference or seminar registration fees

-Hotel expenses (the company allows up to $90 per night for lodging. Anything in excess of this must be paid by the employee).

-The amount of each meal eaten. On the first day of the trip, breakfast is allowed as an expense if the time of departure is before 7 a.m. Lunch is allowed if the time of departure is before 12 noon. Dinner is allowed on the first day if the time of departure is before 6 p.m. On the last day of the trip, breakfast is allowed if the time of arrival is after 8 a.m. Lunch is allowed if the time of arrival is after 1 p.m. Dinner is allowed on the last day if the time of arrival is after 7 p.m. The program should only ask for the amounts of allowable meals. (The company allows up to $9 for breakfast, $12 for lunch, and $16 for dinner. Anything in excess of this must be paid by the employee).

The program should calculate and display the total expenses incurred by the businessperson, the total allowable expenses for the trip, the excess that must be reimbursed by the businessperson, the total allowable expenses for the trip, the excess that must be reimbursed by the businessperson, if any, and the amount saved by the businessperson if the expenses were under the total allowed. Input Validation: Do not accept negative numbers for any dollar amount or for miles driven in a private vehicle. Do not accept numbers less than 1 for the number of days. Only accept valid times for the time of departure and the time of arrival.

Here are the function prototypes I need to use:

int daysSpent();

void times(double &start, double &end);

bool isValidTime(double t);

double airFare();

double carRental();

double vehicle();

double parking(int days);

double taxi(int days);

double registration();

double hotel(int days);

double meals(int days, double arrival, double departure);

double getBreakfast();

double getLunch();

double getDinner();

any help would be greatly appreciated. Thanks.

Explanation / Answer

here is your program : --------->>>>>>>

#include<iostream>

using namespace std;

double vehicle(){
return 0.27;
}

bool isValidTime(double t){
return t >= 1 && t <= 24;
}

double taxi(int days){
return (days*10);
}

void times(double &start, double &end){
while(true){
  cout<<" Enter Time of Departure : ";
  cin>>start;
  if(isValidTime(start)){
   break;
  }else{
   cout<<" wrong time given";
  }
}
while(true){
  cout<<" Enter Time of arrival : ";
  cin>>end;
  if(isValidTime(end)){
   break;
  }else{
   cout<<" wrong time given";
  }
}
}

int daysSpent(){
int days = 0;
while(true){
  cout<<" Enter No. of Days Spent : ";
  cin>>days;
  if(days < 0){
   cout<<" wrong days : ";
  }else{
   break;
  }
}

return days;
}

double parking(int days){
return (6*days);
}

double getMiles(){
double total = 0;
while(true){
  cout<<" Enter Miles Driven By you ..";
  cin>>total;
  if(total < 0){
   cout<<" You Entered wrong value";
  }else{
   break;
  }
}
return total;
}

double carRental(){
double mile;
mile = getMiles();
return (mile*vehicle());
}

double hotel(int days){
return (90.0 * days);
}

double airFare(){
double total = 0;
while(true){
  cout<<" Enter the amount of any air fare round trip ...";
  cin>>total;
  if(total < 0){
   cout<<" You Entered wrong value";
  }else{
   break;
  }
}
return total;
}

double getBreakFast(){
return 9.0;
}

double getLunch(){
return 12.0;
}

double getDinner(){
return 16.0;
}

double meals(int noofday,double timeofdep,double timeofarr){
double total = 0;
if(timeofdep < 7 ){
    total += getBreakFast();
}
if(timeofdep < 12){
  total += getLunch();
}
if(timeofdep < 18){
  total += getDinner();
}
if(noofday > 2)
total = total + (noofday - 2)*37;

if(timeofarr > 8){
  total += getBreakFast();
}
if(timeofarr > 13){
  total += getLunch();
}
if(timeofarr > 19){
  total += getDinner();
}
return total;

}

double registration(){
double total = 0;
while(true){
  cout<<" Enter the registration fee of the conference or seminar ..";
  cin>>total;
  if(total < 0){
   cout<<" You Entered wrong value";
  }else{
   break;
  }
}
return total;
}

void program(){
double start,end;
double total = 0;
int days;
char ch;
times(start,end);
days = daysSpent();
total += airFare();
cout<<" (C)ar Used or (T)axi used : ";
cin>>ch;
if(ch == 'C' || ch == 'c'){
  total += carRental();
  total += parking(days);
}
if(ch == 'T' || ch == 't'){
  total += taxi(days);
}
total += hotel(days);
total += meals(days,start,end);

cout<<" Total Expenses = $"<<total;
}

int main(){
printf("    Welcome To Expenses Calculator ..... ");
program();

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote