Programming Challenge Chapter 3 – Q #2 Stadium Seating – Tony Gaddis – Starting Out With C++
Problem: -
Solution: -
#include <iostream>
#include<iomanip>
using namespace std;
int main()
{
const int CLASS_A = 15,
CLASS_B = 12,
CLASS_C = 9;
float class1, class2, class3;
float total_sale = 0;
cout << "How many Tickets Sale
Of Claas A: $";
cin >> class1;
cout << "How many Tickets Sale
Of Claas B: $";
cin >> class2;
cout << "How many Tickets Sale
Of Claas C: $";
cin >> class3;
class1 = class1 * CLASS_A;
class2 = class2 * CLASS_B;
class3 = class3 * CLASS_C;
total_sale = class1 + class2 + class3;
cout << setprecision(2) << fixed << showpoint;
cout << "Total Sale is $" << total_sale;
return 0;
}
This is the solution of this question
OUTPUT OF THIS QUESTION
Input is highlighted with yellow color.
Explanation of this Solution
- Declare three float constants and initialize the given values.
- Declare another three float variables for input.
- Take input Class 1 from the user by using cin.
- Take input Class 2 from the user by using cin.
- Take input Class 3 from the user by using cin.
- Calculate class 1, class 2 and class 3.
- In last, display Total Sale output on the screen.
- Return 0 to the main function.
Also, I attach CPP file of this problem. You can download this file
0 Comments