#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
void getCustomer( string& custName, int& numAdults, int& numKids,
char&mealType, char& roomType, string& weekday,
float& deposit, ifstream& data);
void custPay( int& adultMeal, int& childMeal, int& foodCost, int& tax, int& roomCost, int& bill, int& owe
, float& surcharge, float& discount);
float GetRoomCost (char roomType);
void printLines(int)
{
for (int i=0; i <= 50; i++)
cout << "-";
}
int main()
{
int numAdults, numKids, adultMeal, childMeal, foodCost, bill, roomCost, owe;
float deposit surcharge, discount;
ifstream data;
string custName, weekday;
char mealType, roomType;
data.open("embassy.dat");
void getCustomer( string& custName, int& numAdults, int& numKids,
char&mealType, char& roomType, string& weekday,
float& deposit);
while(!data.eof())
{
getline(data,custName);
data>>numAdults>>numKids>>mealType>>roomType>>weekday>>deposit;
data.close();
if (!data.is_open())
cout << "The data file could not be opened. The program is stopping.";
return 1;
}
//**************************************************************************************
// Calculate payments
//GetCustomer( variable)
//while ( variable > 0 )
printLines(50);
cout << endl;
cout << "Customer #" << endl;
printLines(50);
cout << endl;
cout << "Number of Adults served:" << numAdults << endl;
cout << "Number of Children served:" << numKids << endl;
cout << "Meal Type:" << mealType << endl;
cout << "Cost of an Adult meal:" << adultMeal << endl;
cout << "Cost of a Child meal:" << childMeal << endl;
cout << "Total Food Cost:" << foodCost << endl;
cout << "Tip and Tax:" << tax << endl;
cout << "Room Cost:" << roomCost << endl;
cout << "Surcharge for weekend:" << surcharge << endl;
printLines(50);
cout << endl;
cout << "TOTAL BILL:" << bill << endl;
cout << "Deposit paid:" << deposit << endl;
printLines(50);
cout << endl;
cout << "YOU OWE" << owe << endl;
cout << "If you pay within 10 days" << endl;
cout << "Your discounted amount is:" << discount << endl;
printLines(50);
cout << endl;
printLines(50);
cout << endl;
//**************************************************************************************
void custPay( int& adultMeal)
if (mealType == 'D' || mealType == 'd')
{
adultMeal = 15.80;
childMeal = adultMeal * 0.6;
}
else if(mealType == 'S' or mealType == 's')
{
adultMeal = 11.75;
childMeal = adultMeal * 0.6;
}
else
cout << "Invalid meal type";
//**************************************************************************************
void custPay( int& foodCost)
{
foodCost = (adultMeal * numAdults) + (childMeal * numKids);
}
//**************************************************************************************
void custPay( int& tax)
{
tax = foodcost * .18;
}
//**************************************************************************************
float GetRoomCost(char roomType)
{
switch(roomType)
{
case 'A': return: 55.00;
case 'B': return: 75.00;
case 'C': return: 85.00;
case 'D': return: 100.00;
case 'E': return: 130.00;
default : cout << "Invalid" <<endl;
cin >> roomCost;
}
}
//**************************************************************************************
void custPay( float& surcharge, string& weekday)
{
if(weekday == 'Saturday' || weekday == 'Friday' || weekday == 'Sunday')
surcharge = 0.07 * (foodCost + roomCost);
else
surcharge = 0;
}
//**************************************************************************************
void custPay( int& bill)
{
bill = roomType + tax + foodCost + surcharge;
}
//**************************************************************************************
void custPay( int& owe)
{
owe = bill - deposit;
}
//**************************************************************************************
void custPay( float& discount)
{
if(bill < 100.00)
discount = bill * 0.005
else if(bill >= 100 && bill < 200)
discount == bill * 0.015
else if(bill >= 200 && bill < 400)
discount == bill * 0.03
else if(bill >= 400 && bill < 800)
discount == bill * 0.04
else if(bill >= 800)
discount == bill * 0.05
}
//**************************************************************************************
return 0;
}