Question: / / This program determines a client's total buffet luncheon cost / / when the number of guests and the per person cost are known.

// This program determines a client's total buffet luncheon cost
// when the number of guests and the per person cost are known.
// It contains a logic error.
#include
#include
using namespace std;
int main()
{
const int ADULT_MEAL_COST =8.25; // Child meal cost =60% of this
int numAdults, // Guests ages 12 and older
numChildren; // Guests ages 2-11
double adultMealTotal, // Total for all adult meals
childMealTotal, // Total for all child meals
totalMealCost;
// Get number of adults and children attending
cout << "This program calculates total cost "
<< "for a buffet luncheon.
";
cout << "Enter the number of adult guests (age 12 and over): ";
cin >> numAdults;
cout << "Enter the number of child guests (age 2-11): ";
cin >> numChildren;
// Calculate meal costs
adultMealTotal = numAdults * ADULT_MEAL_COST;
childMealTotal = numChildren * ADULT_MEAL_COST *.60;
totalMealCost = adultMealTotal + childMealTotal;
// Display total meal cost
cout << fixed << showpoint << setprecision(2);
cout <<"
Total buffet cost is $"<< totalMealCost << endl;
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!