# Travel Expenses

Topics: Expense, Operating expense, Date and time notation by country Pages: 7 (1239 words) Published: November 16, 2012
Problem 1: Travel Expenses
Problem Description: Write a C++ program that calculates and displays the total travel expenses of a business trip. The user must provide the following information:

* Number of days spent on the trip.
* The departure on the first day of the trip, and the time of arrival back home on the last day of the trip. The departure and arrival time must be entered in 12h or 24h formats. Your program should consider AM and PM.

* The amount of meals eaten

The company reimburses travel expenses according to the following policy: Up to \$37.00 per day for meals. The company allows up to \$ 9 for breakfast, \$ 12 for lunch, and \$ 16 for dinner per day. On the first day of the trip, breakfast is allowed as an expense if the time of departure is before 7 AM. 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 PM. On the last day of the trip, breakfast is allowed if the time of arrival is after 8 AM. Lunch is allowed if the time of arrival is after 1 PM. Dinner is allowed on the last day if the time of arrival is after 7 PM. Anything in excess of this must be paid by the employee. It is not necessary reimburse to the company any savings on meals. It can be subtracted to the amount that must be reimbursing to the company. The following Table summarized this point.

The program should calculate and display the following:
* Total expenses incurred by the business person
* The total allowable expenses for the trip
* The excess for that must be paid by the business person, if any * The amount saved by the business person if the expenses were under the total allowed.

These are the specifications and I have it done, because I understand that I have to begin with days and the input validation of this, but I want to optimize the code that I have to calculate the others things.

I have to do the program with these functions

CalcMeals ( ) Calculate and returns the amount reimbursed for meals. CalcMileage ( ) Calculate and returns the amount reimbursed for mileage driven in a private vehicle.
CalcParkingFees ( ) Calculate and returns the amount reimbursed for parking fees. CalcTaxiFees ( ) Calculate and returns the amount reimbursed for taxi charges. CalcLodging ( ) Calculate and returns the amount reimbursed for lodging. CalcTotalReimbursement ( ) Calculate and returns the total amount reimbursed. CalcUnallowed ( ) Calculate and returns the total amount of expenses that are not allowable, if any.

CalcSaved ( ) Calculate and returns the total amount of expenses under the allowable amount, if any. For example, the allowable amount for lodging is \$95.00 per night. If a business person stayed in a hotel for \$85.00 per day for 3 nights, the savings would be \$ 30.00. IVPos ( ) Do not accept negative numbers for any dollar amount or for miles driven in a private vehicle. This function returns a value greater or equal than zero.

IVDays ( ) Do not accept numbers less than 1 for the number of days.

My question or doubt is how can I to optimize the following code to calculate the others calculations using these functions? CalcMeals ( ) Calculate and returns the amount reimbursed for meals. IVDays ( ) Do not accept numbers less than 1 for the number of days.

#include<iostream>
using namespace std;
//global constants
const int pFee=10; //parking fee allowance
const int tFee=20; //taxi fee allowance
const int hFee=95; //hotel fee allowance

//functions prototypes
int IVDays(int,int,int);
void CalcMeals(double);
void CalcMileage(double);
void IVPos(double);
void CalcLodging(double);
void CalcParkingFees(double);
void TaxiFees(double);
void CalcUnallowed(double);
void CalcSaved(double);
void CalcTotalReimbuersement(double);

int main()
{
int numDays=0,numNights, daysTrip;
double meals=0;

CalcMeals(meals);

cout<<endl<<endl;
system("pause");
return 0;
}...