NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#include <iostream>
#include <iomanip>

using namespace std;

// Function prototypes
int getTotalDays();
void getTimeOfDepartureAndArrival(int &departureHour, int &departureMinute, int &arrivalHour, int &arrivalMinute);
double getRoundTripAirfare();
double getCarRentals();
double getVehicleExpenses(double milesDriven);
double getParkingFees(int totalDays);
double getTaxiFees(int totalDays);
double getConferenceFees();
double getHotelExpenses(int totalDays);
double getMealExpenses(int totalDays);

int main()
{
int totalDays, departureHour, departureMinute, arrivalHour, arrivalMinute;
double roundTripAirfare, carRentals, milesDriven, parkingFees, taxiFees, conferenceFees, hotelExpenses, mealExpenses;

// Get input from user
totalDays = getTotalDays();
getTimeOfDepartureAndArrival(departureHour, departureMinute, arrivalHour, arrivalMinute);
roundTripAirfare = getRoundTripAirfare();
carRentals = getCarRentals();
cout << "Enter miles driven: ";
cin >> milesDriven;
parkingFees = getParkingFees(totalDays);
taxiFees = getTaxiFees(totalDays);
conferenceFees = getConferenceFees();
hotelExpenses = getHotelExpenses(totalDays);
mealExpenses = getMealExpenses(totalDays);

// Calculate total expenses
double totalExpenses = roundTripAirfare + carRentals + getVehicleExpenses(milesDriven) + parkingFees + taxiFees + conferenceFees + hotelExpenses + mealExpenses;

// Calculate total allowable expenses
double totalAllowableExpenses = totalDays * (6 + 10 + 90) + 9 * 3 + 12 * 2 + 16 * 2;

// Calculate excess or savings
double excess = totalExpenses - totalAllowableExpenses;
double savings = (excess > 0) ? 0 : -excess;

// Display results
cout << fixed << setprecision(2);
cout << "Total expenses incurred: $" << totalExpenses << endl;
cout << "Total allowable expenses: $" << totalAllowableExpenses << endl;
cout << "Excess to be reimbursed: $" << max(0.0, excess) << endl;
cout << "Amount saved: $" << savings << endl;

return 0;
}

// Implement other functions according to their descriptions
// Remember to define the return types and parameters as specified
// Implement the logic to get user input or perform calculations

int getTotalDays()
{
int totalDays;
cout << "Enter total days spent on the trip: ";
cin >> totalDays;
return totalDays;
}

void getTimeOfDepartureAndArrival(int &departureHour, int &departureMinute, int &arrivalHour, int &arrivalMinute)
{
cout << "Enter time of departure (hour minute): ";
cin >> departureHour >> departureMinute;
cout << "Enter time of arrival (hour minute): ";
cin >> arrivalHour >> arrivalMinute;
}

double getRoundTripAirfare()
{
double roundTripAirfare;
cout << "Enter round-trip airfare: $";
cin >> roundTripAirfare;
return roundTripAirfare;
}

double getCarRentals()
{
double carRentals;
cout << "Enter car rentals cost: $";
cin >> carRentals;
return carRentals;
}

double getVehicleExpenses(double milesDriven)
{
return milesDriven * 0.27;
}

double getParkingFees(int totalDays)
{
int parkingFees = 0;
cout << "Enter parking fees for each day: $" << endl;
for (int i = 0; i < totalDays; ++i)
{
int fee;
cout << "Day " << i + 1 << ": $";
cin >> fee;
parkingFees += fee;
}
return parkingFees;
}

double getTaxiFees(int totalDays)
{
int taxiFees = 0;
cout << "Enter taxi fees for each day (up to $10 per day): $" << endl;
for (int i = 0; i < totalDays; ++i)
{
int fee;
cout << "Day " << i + 1 << ": $";
cin >> fee;
taxiFees += min(fee, 10); // Limit to $10 per day
}
return taxiFees;
}

double getConferenceFees()
{
double conferenceFees;
cout << "Enter conference/seminar registration fees: $";
cin >> conferenceFees;
return conferenceFees;
}

double getHotelExpenses(int totalDays)
{
int hotelExpenses = 0;
cout << "Enter hotel expenses for each night: $" << endl;
for (int i = 0; i < totalDays; ++i)
{
int expense;
cout << "Night " << i + 1 << ": $";
cin >> expense;
hotelExpenses += expense;
}
return hotelExpenses;
}

double getMealExpenses(int totalDays)
{
double mealExpenses = 0;
int breakfastAllowance = 9, lunchAllowance = 12, dinnerAllowance = 16;

// Check if first day's breakfast, lunch, and dinner are allowed
bool firstDayBreakfast = false, firstDayLunch = false, firstDayDinner = false;
int departureHour, departureMinute;
cout << "Enter time of departure (hour minute) on the first day: ";
cin >> departureHour >> departureMinute;
if (departureHour < 7)
firstDayBreakfast = true;
if (departureHour < 12)
firstDayLunch = true;
if (departureHour < 18)
firstDayDinner = true;

// Check if last day's breakfast, lunch, and dinner are allowed
bool lastDayBreakfast = false, lastDayLunch = false, lastDayDinner = false;
int arrivalHour, arrivalMinute;
cout << "Enter time of arrival (hour minute) on the last day: ";
cin >> arrivalHour >> arrivalMinute;
if (arrivalHour >= 8)
lastDayBreakfast = true;
if (arrivalHour >= 13)
lastDayLunch = true;
if (arrivalHour >= 19)
lastDayDinner = true;

// Calculate meal expenses
if (firstDayBreakfast)
mealExpenses += breakfastAllowance;
if (firstDayLunch)
mealExpenses += lunchAllowance;
if (firstDayDinner)
mealExpenses += dinnerAllowance;
if (lastDayBreakfast)
mealExpenses += breakfastAllowance;
if (lastDayLunch)
mealExpenses += lunchAllowance;
if (lastDayDinner)
mealExpenses += dinnerAllowance;

return mealExpenses;
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.