fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. int main() {
  6. int classA, classB, classC;
  7. int const PRICE_A = 15, PRICE_B = 12, PRICE_C = 9;
  8. double incomeA, incomeB, incomeC;
  9. double total;
  10.  
  11. // Get user input
  12. cout << "How many class A tickets were sold ?\n";
  13. cin >> classA;
  14.  
  15. cout << "How many class B tickets were sold ?\n";
  16. cin >> classB;
  17.  
  18. cout << "How many class C tickets were sold ?\n";
  19. cin >> classC;
  20.  
  21. //Calculate the income generated
  22. incomeA = PRICE_A * classA;
  23. incomeB = PRICE_B * classB;
  24. incomeC = PRICE_C * classC;
  25. total = incomeA + incomeB + incomeC;
  26.  
  27. // Display the income
  28. cout << "Softball game income generated\n";
  29. cout << fixed << showpoint << setprecision(2);
  30. cout << "Class A :" << setw(10) << incomeA << endl;
  31. cout << "Class B :" << setw(10) << incomeB << endl;
  32. cout << "Class C :" << setw(10) << incomeC << endl;
  33. cout << "____________________\n";
  34. cout << "Total :" << setw(10) << total << endl;
  35. return 0;
  36. }
Success #stdin #stdout 0.01s 5284KB
stdin
34
60
45
stdout
How many class A tickets were sold ?
How many class B tickets were sold ?
How many class C tickets were sold ?
Softball game income generated
Class A :    510.00
Class B :    720.00
Class C :    405.00
____________________
Total   :   1635.00