Answered step by step
Verified Expert Solution
Link Copied!

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 9: 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 MAX_BREAKFAST =9.00;
// Maximum daily lunch amount.
const double MAX_LUNCH =12.00;
// Maximum daily dinner amount.
const double MAX_DINNER =16.00;
// Global variable to hold total expenses of employee
double totalExpenses =0;
// Function prototypes
// TODO: Add remaining function prototypes
void displayExpenseTotals(double allowable);
int daysSpent();
void times(double&, double&);
double getBreakfast();
double getLunch();
double getDinner();
double excess();
double total();
double isValidTime();
double meals(int, double, double);
int main(){
double allowable =0; // Total allowable expenses
double time1; // Departure time on first trip day
double time2; // 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 time1 and time2 by referece)
// TODO
times(time1, time2);
cout << "Departure time: "<< time1<< endl;
cout << "Arrival time: "<< time2<< endl;
// Get allowable meal expenses.
//(pass days, time1, and time2 as value)
// returns allowable expenses
// TODO
allowable = meals(days, time1, time2);
// Display Totals (pass allowable as value).
// TODO
displayExpenseTotals(allowable);
return 0;
}
//********************************************************
// 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 isValidTime(int hh, int mm){
bool status = true; // Status flag, initialized to true
// Determine if the time is invalid.
// hh needs to be betwen 0 and 23 inclusive
// mm needs to be between 0 and 59 inclusive
// TODO
if (hh <=23 && mm <=59){
status = true;
} else {
status = false;
}
return status;
}
void times(double& start, double& end){
int hh, mm;
cout << "Enter the departure time (HH MM): "<< endl;
cin >> hh >> mm;
while (!isValidTime(hh, mm)){
cout << "Invalid number (23 is the max HH and 59 is the max MM)."<< endl;
cout << "Reenter the departure time (HH MM): "<< endl;
cin >> hh >> mm;
}
start = hh +(mm /100.0);
cout << "Enter the return time (HH MM): "<< endl;
cin >> hh >> mm;
while (!isValidTime(hh, mm)){
cout << "Invalid number (23 is the max HH and 59 is the max MM)."<< endl;
cout << "Reenter the return time (HH MM): "<< endl;
cin >> hh >> mm;
}
}
double meals(int days, double depart, double arrive){
double meals =0; // To hold the total meal costs.
// Handle special case of a one day trip.
// Breakfast allowed if depart before 7am and arrive 8am or after
// Lunch allowed if depart before 12pm and arrive 1pm or after
// Dinner allowed if depart before 6pm and arrive 7pm or after
if (days ==1){
if (depart <7 && arrive >=8){
if (meals += getBreakfast()){
totalExpenses += meals;
}
}
// Get meal amounts allowed for the first day.
else {
cout << "Day 1:
";
}
if (depart <12 && arrive >=13){
if (meals += getLunch()){
totalExpenses += meals;
} else {
cout << "Day 1:
";
}
}
if (depart <18 && arrive >=19){
if (meals += getDinner()){
totalExpenses += meals;
} else {
cout << "day 1:
";
}
}
}
while (depart >=s 18){
cout <<"No meals will be paid for if your departure is after 6:00pm";
}
if (depart <=7){
getBreakfast();
}
if (depart <=12){
getLunc

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions

Question

What is tone at the top? Corporate culture?

Answered: 1 week ago

Question

5. What decision-making model would you advocate to this person?

Answered: 1 week ago

Question

Determine miller indices of plane A Z a/2 X a/2 a/2 Y

Answered: 1 week ago

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago