Struggling to complete this program

I am having some trouble finishing this exercise here. I am supposed to have this program run normally, then ask for an employee ID or name, and then store the data under that name in a txt file, and then loop the program. I have the entire program finished, just stuck on having to put in that loop and have the txt file store the data under the user input name/number. How do I solve this? (the code is very long, I will add it in a comment.)

 
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;

int numDays(int);
double getDepartureTime(double);
double getArrivalTime(double);
double getRoundTripFares(double);
double getCarRentalCost(double);
double getMilesDriven(double);
double getParkingFees(double);
double getTaxiFees(double);
double getRegistrationFees(double);
double getHotelExpenses(double);

double getAllowableMeals(double, double, double &, double &, double &,
double &, double &, double &);

void calcTotalCost(int, double, double, double, double, double, double,
double, double, double, double, double, double,
double, double, double, double miles = 0.27,
double parking = 6.0, double taxi = 10.0,
double hotel = 90.0, double breakfast = 9.0,
double lunch = 12.0, double dinner = 16.0);

int main()
{
ofstream outputFile;
outputFile.open("Expenses.txt");

static int daysOnTrip = 0;

static double timeOfDeparture = 0.0,
timeOfArrival = 0.0,
roundTripFares = 0.0,
carRentalCost = 0.0,
milesDriven = 0.0,
parkingFees = 0.0,
taxiFees = 0.0,
registrationFees = 0.0,
hotelExpenses = 0.0,
breakfastFirstDay = 0.0,
lunchFirstDay = 0.0,
dinnerFirstDay = 0.0,
daysOnTrip = numDays(daysOnTrip);
timeOfDeparture = getDepartureTime(timeOfDeparture);
timeOfArrival = getArrivalTime(timeOfArrival);
roundTripFares = getRoundTripFares(roundTripFares);
carRentalCost = getCarRentalCost(carRentalCost);
milesDriven = getMilesDriven(milesDriven);
parkingFees = getParkingFees(parkingFees);
taxiFees = getTaxiFees(taxiFees);
registrationFees = getRegistrationFees(registrationFees);
hotelExpenses = getHotelExpenses(hotelExpenses);

allowableMeals = getAllowableMeals(timeOfDeparture, timeOfArrival,
breakfastFirstDay, lunchFirstDay,
dinnerFirstDay, breakfastLastDay,
lunchLastDay, dinnerLastDay);

calcTotalCost(daysOnTrip, timeOfDeparture, timeOfArrival, roundTripFares,
carRentalCost, milesDriven, parkingFees, taxiFees,
registrationFees, hotelExpenses, breakfastFirstDay,
lunchFirstDay, dinnerFirstDay, breakfastLastDay,
lunchLastDay, dinnerLastDay);

outputFile.close();

return 0;
}


int numDays(int daysOnTrip)
{
cout << "How many days did you spend on this business trip? ";
cin >> daysOnTrip;


while (daysOnTrip < 1)
{
cout << "\nInvalid input. The number of days spent on a trip\n"
<< "has to be greater than or equal to 1.\n"
<< "How many days have you spent on this business trip? ";
cin >> daysOnTrip;
}

return daysOnTrip;
}

double getDepartureTime(double departureTime)
{
cout << "\nAt what time was your departure on the first day? ";
cin >> departureTime;

while (departureTime < 0 || departureTime > 24.00)
{
cout << "\nInvalid input. The departure time can not be\n"
<< "negative. Example Input: 00.00 - 24.00\n"
<< "At what time was your departure on the first day? ";
cin >> departureTime;
}
}

return arrivalTime;
}

double getRoundTripFares(double roundTripFares)
{
cout << "\nWere there any round trip airfares? $ ";
cin >> roundTripFares;

while (roundTripFares < 0)
{
cout << "\nInvalid input. The amount of airfares can not\n"
<< "be negative.\n"
<< "Were there any round trip airfares? $ ";
cin >> roundTripFares;
}

return roundTripFares;
}

double getCarRentalCost(double carRentalCost)
{
cout << "\nHave you had any car rental cost? $ ";
cin >> carRentalCost;

while (carRentalCost < 0)
{
cout << "\nInvalid input. The amount of car rental cost can not\n"
<< "be negative.\n"
<< "\nHave you had any car rental cost? $ ";
cin >> carRentalCost;
}

return carRentalCost;
}

double getMilesDriven(double milesDriven)
{
cout << "\nHow many miles have you driven in your own car? ";
cin >> milesDriven;

while (milesDriven < 0)
{
cout << "\nInvalid input. The number of miles driven can not\n"
<< "be negative.\n\n"
<< "\nHow many miles have you driven in your own car? ";
cin >> milesDriven;
}

return milesDriven;
}

double getParkingFees (double parkingFee

while (parkingFees < 0)
{
cout << "\nInvalid input. The parking fees can not be negative.\n\n"
<< "Have you had to pay any parking fees? $ ";
cin >> parkingFees;
}

return parkingFees;
}

double getTaxiFees (double taxiFees)
{
cout << "\nWere there any taxi fees? $ ";
cin >> taxiFees;

while (taxiFees < 0)
{
cout << "\nInvalid input. The taxi fees can not be negative.\n\n"
<< "Were there any taxi fees? $ ";
cin >> taxiFees;
}

return taxiFees;
}

double getRegistrationFees (double registrationFees)
{
cout << "\nWere there any conference or seminar registration fees? $ ";
cin >> registrationFees;

while (registrationFees < 0)
{
cout << "\nInvalid input. The registration fee can not be negative.\n"
<< "Were there any conference or seminar registration fees? $ ";
cin >> registrationFees;
}

return registrationFees;
}

double getHotelExpenses(double hotelExpenses)
{
cout << "\nHave you had any hotel expenses? $ ";
cin >> hotelExpenses;

while (hotelExpenses < 0)
{
cout << "\nInvalid input. The hotel expenses can not be negative.\n"
<< "Have you had any hotel expenses? $ ";
cin >> hotelExpenses;
}

return hotelExpenses;
}

double getAllowableMeals(double timeOfDeparture, double timeOfArrival,
double &breakfastFirstDay, double &lunchFirstDay,
double &dinnerFirstDay, double &breakfastLastDay,
double &lunchLastDay, double &dinnerLastDay)
{
double amountAllowableMeals = 0.0;

if (timeOfDeparture > 07.00)
{
cout << "\nHow much did you pay for breakfast on your first day? $ ";
cin >> breakfastFirstDay;
}

while (breakfastFirstDay < 0.0)
{
cout << "\nInvalid input. The cost for breakfast can not be negative.\n"
<< "How much did you pay for breakfast on your first day? $ ";
cin >> breakfastFirstDay;
}

if (timeOfDeparture < 12.00)
{
cout << "\nHow much did you pay for lunch on your first day? $ ";
cin >> lunchFirstDay;
}

while (lunchFirstDay < 0.0)
{
cout << "\nInvalid input. The cost for lunch can not be negative.\n"
<< "How much did you pay for lunch on your first day? $ ";
cin >> lunchFirstDay;
}

if (timeOfDeparture < 18.00)
{
cout << "\nHow much did you pay for dinner on your first day? $ ";
cin >> dinnerFirstDay;
}

while (dinnerFirstDay < 0.0)
{
cout << "\nInvalid input. The cost for dinner can not be negative.\n"
<< "How much did you pay for dinner on your first day? $ ";
cin >> dinnerFirstDay;
}

if (timeOfArrival < 08.00)
{
cout << "\nHow much did you pay for breakfast on your last day? $ ";
cin >> breakfastLastDay;
}

while (breakfastLastDay < 0.0)
{
cout << "\nInvalid input. The cost for breakfast can not be negative.\n"
<< "How much did you pay for breakfast on your last day? $ ";
cin >> breakfastLastDay;
}

if (timeOfArrival > 13.00)
{
cout << "\nHow much did you pay for lunch on your last day? $ ";
cin >> lunchLastDay;
}

while (lunchLastDay < 0.0)
{
cout << "\nInvalid input. The cost for lunch can not be negative.\n"
<< "How much did you pay for lunch on your last day? $ ";
cin >> lunchLastDay;
}

if (timeOfArrival > 19.00)
{
cout << "\nHow much did you pay for dinner on your last day? $ ";
cin >> dinnerLastDay;
}

while (dinnerLastDay < 0.0)
{
cout << "\nInvalid input. The cost for breakfast can not be negative.\n"
<< "How much did you pay for dinner on your last day? $ ";
cin >> dinnerLastDay;
}

return amountAllowableMeals;
}

void calcTotalCost(int numDays, double timeDeparture, double timeArrival,
double costAirFare, double costCarRental, double costPerMile,
double costParking, double costTaxi, double costRegistration,
double costHotel, double costBreakfastFirst, double costLunchFirst,
double costDinnerFirst, double costBreakfastLast, double costLunchLast,
double costDinnerLast, double costMilesCovered, double costTaxiCovered,
double costParkingCovered, double costHotelCovered,
double costBreakfastCovered, double costLunchCovered,
double costDinnerCovered)
{
double privateCostCar = 0.0,
privateCostHotel = 0.0,
privateCostTaxi = 0.0,
privateCostBreakfast = 0.0,
privateCostLunch = 0.0,
privateCostDinner = 0.0,
privateCostTotal = 0.0,
costSubtotal = 0.0,
costTotal = 0.0;

cout << fixed << showpoint << setprecision(2);

cout << "\n\n\t\tBusiness Trip Expenses\n\n"
<< "Number of Days:\t\t"
<< setw(26) << right << numDays
<< setw(15) << right
<< "\nTime of Departure:\t\t"
<< setw(21) << right << timeDeparture
<< setw(15) << right
<< "\nTime of Arrival:\t\t"
<< setw(21) << right << timeArrival
<< setw(15) << right
<< "\n\nCost of Air Fare:\t\t"
<< setw(13) << right << "$ "
<< setw(8) << right << costAirFare
<< "\nCost of Car Rental:\t\t"
<< setw(13) << right << "$ "
<< setw(8) << right << costCarRental
<< "\nCost of Taxi Fare:\t\t"
<< setw(13) << right << "$ "
<< setw(8) << right << costTaxi
<< "\nCost of Registration:\t\t"
<< setw(13) << right << "$ "
<< setw(8) << right << costRegistration
<< "\nCost of Overnight Hotel stay:\t\t"
<< setw(5) << right << "$ "
<< setw(8) << right << costHotel
<< "\nCost of Breakfast on First Day:\t\t"
<< setw(5) << right << "$ "
<< setw(8) << right << costBreakfastFirst
<< "\nCost of Lunch on First Day:\t\t"
<< setw(5) << right << "$ "
<< setw(8) << right << costLunchFirst
<< "\nCost of Dinner on First Day:\t\t"
<< setw(5) << right << "$ "
<< setw(8) << right << costDinnerFirst
<< "\nCost of Breakfast on Last Day:\t\t"
<< setw(5) << right << "$ "
<< setw(8) << right << costBreakfa
cout << "\n\nSub-Total: "
<< setw(34) << right << "$ "
<< setw(8) << right << costSubtotal;

privateCostCar = costMilesCovered * costPerMile / costPerMile;

if (costHotel > costHotelCovered)
{
privateCostHotel = costHotel - costHotelCovered * numDays;
}

if (costTaxi > costTaxiCovered)
{
privateCostTaxi = costTaxi - costTaxiCovered * numDays;
}

if ((costBreakfastFirst + costBreakfastLast) > costBreakfastCovered)
{
privateCostBreakfast = (costBreakfastFirst + costBreakfastLast) - costBreakfastCovered;
}

if ((costLunchFirst + costLunchLast) > costLunchCovered)
{
privateCostLunch = (costLunchFirst + costLunchLast) - costLunchCovered;
}

if ((costDinnerFirst + costDinnerLast) > costDinnerCovered)
{
privateCostDinner = (costDinnerFirst + costDinnerLast) - costDinnerCovered;
}

privateCostTotal = privateCostCar + privateCostHotel + privateCostTaxi +
privateCostBreakfast + privateCostLunch + privateCostDinner;

cout << "\n\nThe following expenses are not covered: \n\n"

<< "Miles Driven:\t\t"
<< setw(21) << right << "$ "
<< setw(8) << right << privateCostCar
<< "\nStay in Hotel:\t\t"
<< setw(21) << right << "$ "
<< setw(8) << right << privateCostDinner;

costTotal = costSubtotal + privateCostTotal;

cout << "\n\nThe total cost of this trip is:\t\t"
<< setw(5) << right << "$ "
<< setw(8) << right << costTotal;


}
Topic archived. No new replies allowed.