Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help clean this up / / / / Week 9 : Travel Expenses / / You work for a company that provides employees with a
Help clean this up
Week : Travel Expenses
You work for a company that provides employees with a credit card for
business travel expenses. The company has set limits on expenses. If an
employee spends over those limits they must reimburse the company.
For this project will focus on just food expenses
breakfast lunch, and dinner
#include
#include
using namespace std;
Constants
Maximum daily breakfast amount.
const double MAXBREAKFAST ;
Maximum daily lunch amount.
const double MAXLUNCH ;
Maximum daily dinner amount.
const double MAXDINNER ;
Global variable to hold total expenses of employee
double totalExpenses ;
Function prototypes
TODO: Add remaining function prototypes
void displayExpenseTotalsdouble allowable;
int daysSpent;
void timesdouble& double&;
double getBreakfast;
double getLunch;
double getDinner;
double excess;
double total;
double isValidTime;
double mealsint double, double;
int main
double allowable ; Total allowable expenses
double time; Departure time on first trip day
double time; Arrival home time on last day of trip
int days; Number of days spent on the trip
Get the number of days for the trip.
TODO
days daysSpent;
cout "days entered: days endl; for testing
Get the arrival and departure times.
pass time and time by referece
TODO
timestime time;
cout "Departure time: time endl;
cout "Arrival time: time endl;
Get allowable meal expenses.
pass days, time and time as value
returns allowable expenses
TODO
allowable mealsdays time time;
Display Totals pass allowable as value
TODO
displayExpenseTotalsallowable;
return ;
The displayExpenseTotals function displays 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.
TODO
The daysSpent function asks for the number of days
spent on the trip and returns the value as an integer.
TODO
int daysSpent
int daysSpent;
cout "How many days were you on this trip? endl;
cin daysSpent;
cin.ignore;
return daysSpent;
bool isValidTimeint hh int mm
bool status true; Status flag, initialized to true
Determine if the time is invalid.
hh needs to be betwen and inclusive
mm needs to be between and inclusive
TODO
if hh && mm
status true;
else
status false;
return status;
void timesdouble& start, double& end
int hh mm;
cout "Enter the departure time HH MM: endl;
cin hh mm;
while isValidTimehh mm
cout "Invalid number is the max HH and is the max MM endl;
cout "Reenter the departure time HH MM: endl;
cin hh mm;
start hh mm ;
cout "Enter the return time HH MM: endl;
cin hh mm;
while isValidTimehh mm
cout "Invalid number is the max HH and is the max MM endl;
cout "Reenter the return time HH MM: endl;
cin hh mm;
double mealsint days, double depart, double arrive
double meals ; To hold the total meal costs.
Handle special case of a one day trip.
Breakfast allowed if depart before am and arrive am or after
Lunch allowed if depart before pm and arrive pm or after
Dinner allowed if depart before pm and arrive pm or after
if days
if depart && arrive
if meals getBreakfast
totalExpenses meals;
Get meal amounts allowed for the first day.
else
cout "Day :
;
if depart && arrive
if meals getLunch
totalExpenses meals;
else
cout "Day :
;
if depart && arrive
if meals getDinner
totalExpenses meals;
else
cout "day :
;
while depart s
cout No meals will be paid for if your departure is after :pm;
if depart
getBreakfast;
if depart
getLunc
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started