I'm a little confused on this assignment. I've done most of the program but am a little confused by the call to the second function. Thought I was doing well and felt good about getting as far as I did before the current confusion or lack of knowledge. The instructions are:

A value-returning function named calcTravelCost that accepts cost per day and number of days and returns the total cost (overloaded functions).

 The main function will request the fuel cost, number of days, waste disposal fee, and ask if there is a miscellaneous expense. If ‘Y’ it will ask for the amount and call the first calcTravelCost function. If ‘N’ then it will call the first calcTravelCost using a default value. This calcTravelCost will call the second calcTravelCost appropriately. Continue looping for more expenses until -999 is entered for fuel cost.

Here is what I have so far that compiles and runs correctly. Thanks in advance for looking/attempting to help.
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106`` ``````//Joe Snuffy //CSCI 1010 W1 //PASS 10 /*Space Travel Company program that will calculate the total cost for travel using reference parameters, overloaded functions and value returning functions.*/ #include #include #include #include using namespace std; /*function prototype...the misc variable will be set to a default value if the parameters are unchanged the default value will be used.*/ double calcTravelCost(double &fuelCost, double &foodCost, double &oxyCost, double &wasteCost, double miscCost); double calcTravelCost(double &perDay, double &total, int &nbrOfDays); //declare constant GLOBAL variables const double OXYGEN_PERDAY = 25.00; const double FOOD_PERDAY = 35.00; //declare additional variables double fuelCost = 0; //initialize double fuelTotal = 0; double foodCost = 0; double oxyCost = 0; double wasteCost = 0; double miscCost = 0; double totalCost = 0; int nbrOfDays = 0; int main() { //variable to hold user choice for Y or N char userChoice = ' '; //Prompt user for input cout<<"Welcome to Joe Snuffy Space Travel Company"<>fuelCost; while(fuelCost != -999) { cout<<"Enter the number of days: "; cin>>nbrOfDays; cout<<"Enter the waste disposal cost: "; cin>>wasteCost; cout<<"Is there a miscellaneous cost? (Y or N): "; cin>>userChoice;//character variable if(userChoice == 'Y' || userChoice == 'y') { cout<<"Please enter the miscellaneous expense cost: "; cin>>miscCost; //call to first function calcTravelCost(fuelCost, foodCost, oxyCost, wasteCost, miscCost); cout<>fuelCost; } system("Pause"); return 0; }//return //overloaded function defintions double calcTravelCost(double &fuelCost, double &foodCost, double &oxyCost, double &wasteCost, double miscCost) { fuelTotal = fuelCost * nbrOfDays; foodCost = FOOD_PERDAY * nbrOfDays; oxyCost = OXYGEN_PERDAY * nbrOfDays; totalCost = fuelCost + foodCost + oxyCost + wasteCost + miscCost; return totalCost; } double calcTravelCost(double &perDay, double &total, int &nbrOfDays) { }``````
Exactly what you done for the first function you would do for the second. Just instead of passing 5 parameters you will now pass 3 instead. Function overloading allows you to name a function exactly the same as another provided u pass a different variables to it. In this case using 5 and three should work perfectly.
Seriously? This assignment seem way to easy for what I've been able to accomplish with minimal assistance here. This is the completed assignment. It compiles all scenarios correctly but I just don't trust the work was supposed to be completed by someone with my skills so soon. Here is more of the assignment if this helps. I really want to do my best and understand so to me it is important that I get it right.

Write the C++ code that will contain 2 functions (besides the main function):
 A value-returning function named calcTravelCost
o that accepts at least
 the fuel cost,
 number of days of space travel,
 waste disposal cost.
o If there is a miscellaneous expense, it will accept it. If there is not a miscellaneous expense, have a default value of 0.
o This function will,
 by reference parameters, pass back
 the cost of the oxygen (all days)
 and the cost of the food (all days)
 and return the total cost (by return statement).
 A value-returning function named calcTravelCost that accepts cost per day and number of days and returns the total cost (overloaded functions).
 The main function will request the fuel cost, number of days, waste disposal fee, and ask if there is a miscellaneous expense. If ‘Y’ it will ask for the amount and call the first calcTravelCost function. If ‘N’ then it will call the first calcTravelCost using a default value. This calcTravelCost will call the second calcTravelCost appropriately. Continue looping for more expenses until -999 is entered for fuel cost.

And here is my program

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115`` ``````//Joe Snuffy //CSCI 1010 W1 //PASS 10 /*Space Travel Company program that will calculate the total cost for travel using reference parameters, overloaded functions and value returning functions.*/ #include #include #include #include using namespace std; /*function prototype...the misc variable will be set to a default value if the parameters are unchanged the default value will be used.*/ double calcTravelCost(double &fuelCost, double &foodCost, double &oxyCost, double &wasteCost, double miscCost=0); double calcTravelCost(double &costPerDay, double &totalCost, int &nbrOfDays); //declare constant GLOBAL variables const double OXYGEN_PERDAY = 25.00; const double FOOD_PERDAY = 35.00; double fuelCost; double fuelTotal; double foodCost; double oxyCost; double wasteCost; double miscCost; double totalCost; double costPerDay; int nbrOfDays; //declare additional variables int main() { //variable to hold user choice for Y or N char userChoice = ' '; //Prompt user for input cout<<"Welcome to Joe Snuffy Space Travel Company"<>fuelCost; while(fuelCost != -999) { cout<<"Enter the number of days: "; cin>>nbrOfDays; cout<<"Enter the waste disposal cost: "; cin>>wasteCost; cout<<"Is there a miscellaneous cost? (Y or N): "; cin>>userChoice;//character variable cout<>miscCost; //call to first function calcTravelCost(fuelCost, foodCost, oxyCost, wasteCost, miscCost); cout<>fuelCost; } system("Pause"); return 0; }//return //overloaded function defintions double calcTravelCost(double &fuelCost, double &foodCost, double &oxyCost, double &wasteCost, double miscCost) { fuelTotal = fuelCost * nbrOfDays; foodCost = FOOD_PERDAY * nbrOfDays; oxyCost = OXYGEN_PERDAY * nbrOfDays; totalCost = fuelCost + foodCost + oxyCost + wasteCost + miscCost; return totalCost; } double calcTravelCost(double &perDay, double &total, int &nbrOfDays) { fuelTotal = fuelCost * nbrOfDays; foodCost = FOOD_PERDAY * nbrOfDays; oxyCost = OXYGEN_PERDAY * nbrOfDays; costPerDay = fuelCost + foodCost + oxyCost + wasteCost; totalCost = costPerDay; return totalCost; } ``````
Topic archived. No new replies allowed.