On line 69 I receive an error saying that total is not declared in this scope, I am unsure what I did wrong.
// Program description: This program will calculate the cost of a guest staying at a hotel.
// *******************************************************************************************
#include <iostream>
#include <fstream>
using namespace std;
ofstream myfile ("HotelInvoice.txt");
if (myfile.is_open())
{
myfile << "This is the total member cost: $" << discountCost << endl;
myfile << "This is the total non-member cost: $" << nTotalCost << endl;
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
//**********************************************************************************
// void membership
// this function returns a char to show whether a customer is a member or not
//
// return value
// ------------------
// char
//
// Parameters
// ------------------
// *********************************************************************************
char membership()
{
char letter;
cout << "Enter your choice (M = Member or N = Non-member): " << endl;
cin >> letter;
while(letter != 'M' && letter != 'm' && letter != 'N' && letter != 'n')
{
cout << "Please enter M or N: " << endl;
cin >> letter;
return letter;
}
}
//****************************************************************
// void mCost*
// This function calculates the cost of stay for members
//
// return value
// ---------------
// float
//
// Parameters
// ---------------
// float rCost, float nights
//****************************************************************
in "discountCost = mCost(rCost, nights, total, memberDiscount);" total was not declared.
After that I got that your "char getMembership()" is not named properly at the end of the code, it just say "char membership()"
2) In your main() function, you're attempting to use a variable called total, in your call to mCost(). But you haven't declared that variable anywhere in main().