Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/ / 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

This Question: 1 pt

Answered: 1 week ago