Write a program that calculates and displays the total trave
Write a program 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, if any, and the amount saved by the businessperson if the expenses were under the total allowed.
Must be written in Visual Studios
Solution
#include<iostream>
#include <iomanip>
using namespace std;
//function prototype
int numberOfDays(int totalDays);
double times(double departureTime,double arrivalTime);
double airfare(double amtfare);
double carRental(double amtCar);
double calculateMileage(double mlg);
double calculateParkingFees(double parking);
double calculateTaxiFees(double taxi);
double registration(double regFees);
double calculateLodging(double hotel);
//main function
void main()
{
//variable declartion
int numDays, days;
double departure, arrival, time, amtAirfare, totalAirfare, amtCarRental, totalAmtCarRental;
double miles,totalMiles,parkingFees,totalParkingFees,taxiFees,totalTaxiFees,regFees,totalRegFees;
double amtHotel,totalAmtHotel;
//Prompt the user to enter input
cout << \"Enter total number of days spent on the trip: \";
cin >> numDays;
days = numberOfDays(numDays);
cout << \"The time of departure on the first day of the trip:(hh) \";
cin >> departure;
cout << \"The time of arrival back home on the last day of the trip:(hh) \";
cin >> arrival;
time = times(departure, arrival);
cout << \"Enter total amount of airfare round-trip :$ \";
cin >> amtAirfare;
totalAirfare = airfare(amtAirfare);
cout << \"Enter total amount of car rentals :$ \";
cin >> amtCarRental;
totalAmtCarRental = carRental(amtCarRental);
cout << \"Enter total miles driven : \";
cin >> miles;
totalMiles = calculateMileage(miles);
cout << \"Enter parking fees :$ \";
cin >> parkingFees;
totalParkingFees = calculateParkingFees(parkingFees);
cout << \"Enter Taxi fees :$ \";
cin >> taxiFees;
totalTaxiFees = calculateTaxiFees(taxiFees);
cout << \"Enter Conference or Seminar registration fees : \";
cin >> regFees;
totalRegFees = registration(regFees);
cout << \"Enter amount of hotel expenses : \";
cin >> amtHotel;
totalAmtHotel = calculateLodging(amtHotel);
int numberOfDays(int totalDays)
{
return totalDays;
}
double times(double departureTime,double arrivalTime)
{
return departureTime;
}
double airfare(double amtFare)
{
return amtFare;
}
double carRental(double amtCar)
{
return amtCar;
}
double calculateMileage(double mlg)
{
double mileage;
mileage = (mlg * 0.27);
return mileage;
}
double calculateParkingFees(double parking)
{
double totalFees;
double extra;
if(parking <= 10)
return parking;
else
{
extra = (parking - 10);
totalFees = extra + 10;
return totalFees;
}
}
double calculateTaxiFees(double taxi)
{
double totaltaxi;
double extra;
if(taxi <= 20 )
return taxi;
else
{
extra = (taxi - 20);
totaltaxi = extra + 20;
return totaltaxi;
}
}
double registration(double regFees)
{
return regFees;
}
double calculateLodging(double hotel)
{
double totalHotel,extra;
if(hotel <=90)
return hotel;
else
{
extra = (hotel - 90);
totalHotel = extra + 90;
return totalHotel;
}
}
//Display output
cout << endl << \"Total days of trip: \" << days << endl;
cout << \"Total airfare:$ \" << totalAirfare << endl;
cout << \"Total car rental:$ \" << totalAmtCarRental << endl;
cout << \"Total miles driven cost: \" << totalMiles << \"miles\"<< endl;
cout << \"Total parking fees:$ \" << totalParkingFees << endl;
cout << \"Total taxi fees:$ \" << totalTaxiFees << endl;
cout << \"Total registration fees:$ \" << totalRegFees << endl;
cout << \"Total lodging fees:$ \" << totalAmtHotel << endl;
}


