Write a program that calculates and displays the total travel expenses of a busi
ID: 3777164 • Letter: W
Question
Write a program that calculates and displays the total travel
expenses of a business person 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. Vehicle allowance is $0.58 per mile.
• Parking fees. (The company allows up to $12 per day. Anything in excess of this
must be paid by the employee.)
• Taxi fees. (The company allows up to $40 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 cost 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 noon. Dinner is allowed 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 if the time of
arrival is after 7 p.m. The program should only ask for the costs of allowable meals.
(The company allows up to $18 for breakfast, $12 for lunch, and $20 for dinner.
Anything in excess of this must be paid by the employee.)
The program should perform the necessary calculations to determine the total amount
spent by the business traveler in each category (mileage charges, parking, hotel, meals, etc.)
as well as the maximum amount allowed in each category. It should then create a well laid
out expense report that includes the amount spent and the amount allowed in each category,
as well as the total amount spent and total amount allowed for the entire trip. This
report should be written to a file.
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.
Explanation / Answer
Here is the required program what you have want
#include <iostream>
using namespace std;
int totalDays;
double departureTime;
double arrivalTime;
double airfareAmount;
double carRental;
double privateVehicle;
double privateVehicleexpense;
double parkingFee;
double taxiFee;
double conf_regFee;
double hotelAmount;
double totalExpense;
double totalAllowexpense;
int main()
{
int totalDaysin;
double departureTimein;
double arrivalTimein;
double airfareAmountin;
double carRentalin;
double privateVehiclein;
double parkingFeein;
double taxiFeein;
double conf_regFeein;
double hotelAmountin;
cout << "Enter total number of days spent on the trip : ";
cin >> totalDaysin;
cout << " Enter the departure time on the first day of the trip (19.20) : ";
cin >> departureTimein;
cout << " Enter the arrival time on the last day of the trip (19.20) : ";
cin >> arrivalTimein;
cout << " Enter total amount spent on round-trip airfare : RM ";
cin >> airfareAmountin;
cout << " Enter total amount spent on car rentals : RM ";
cin >> carRentalin;
cout << " Enter total kilometres driven : ";
cin >> privateVehiclein;
cout << " Enter total parking fees : RM ";
cin >> parkingFeein;
cout << " Enter total taxi fees : RM ";
cin >> taxiFeein;
cout << " Enter total conference or seminar registration fees : RM ";
cin >> conf_regFeein;
cout << " Enter total hotel expenses : RM ";
cin >> hotelAmountin;
cout << " Total days spent on trip : " << totalDaysin << " Days " << endl;
cout << " Departure time on first day of trip : " << departureTimein << endl;
cout << " Arrival time on last day of trip : " << arrivalTimein << endl;
cout << " Total round-trip airfare : RM " << airfareAmountin << endl;
cout << " Total car rental fee : RM " << carRentalin << endl;
cout << " Total kilometres driven for private vehicle : " << privateVehiclein << " Kilometres " << endl;
privateVehicleexpense = privateVehiclein * 4.00;
cout << " Total private vehicle expenses : RM " << privateVehicleexpense << endl;//calculation
cout << " Total parking fees : RM " << parkingFeein << endl;
cout << " Total taxi fees : RM " << taxiFeein << endl;
cout << " Total conference or seminar registration fees : RM " << conf_regFeein << endl;
cout << " Total hotel expenses : RM " << hotelAmountin << endl ;
totalExpense = airfareAmountin + carRentalin + privateVehicleexpense + parkingFeein + taxiFeein + conf_regFeein + hotelAmountin;
cout << " Total expenses : RM " << totalExpense << endl;//calculation
totalAllowexpense = airfareAmountin + carRentalin + privateVehicleexpense + 6.00 + 10.00 + conf_regFeein + 180.00 ;
cout << " Total allowable expenses : RM " << totalAllowexpense << endl;//calculation
cout << " " ;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.