fork download
  1. //Xinnuo Wang CS1A chapter 3 , P.143, #2
  2. //
  3. /*******************************************************************************
  4. *
  5. * Caculate Stadium Seating Income
  6. *-------------------------------------------------------------------------------
  7. * This program asks how many tickets for each class of seats were sold, then
  8. * displays the amount of income generated from ticket sales.
  9. *
  10. * computation is based on the formula:
  11. * Total = Numb1 x Unit price of ClassA+ Numb2 x Unit price of ClassB+Numb3 x Unit price of ClassC
  12. *-------------------------------------------------------------------------------
  13. * INPUT
  14. * numb1 : The amount of solded class A seats
  15. * numb2 : The amount of solded class B seats
  16. * numb3 : The amount of solded class C seats
  17. * unitPriceA : The unit price of class A seats.
  18. * unitPriceB : The unit price of class B seats.
  19. * unitPriceC : The unit price of class c seats.
  20. * OUTPUT
  21. * total : The amount of income generated from ticket sales
  22. *
  23. *******************************************************************************/
  24. #include <iostream>
  25. #include <iomanip>
  26. using namespace std;
  27.  
  28. int main()
  29. {
  30. int unitPriceA; //INPUT - The unit price of class A seats.
  31. int unitPriceB; //INPUT - The unit price of class B seats.
  32. int unitPriceC; //INPUT - The unit price of class C seats.
  33. int numb1; //INPUT - The amount of solded class A seats
  34. int numb2; //INPUT - The amount of solded class B seats
  35. int numb3; //INPUT - The amount of solded class C seats
  36. double total; //OUTPUT - The amount of income generated from ticket sales
  37. //
  38. //Initialize Program Variables
  39. unitPriceA = 15;
  40. unitPriceB = 12;
  41. unitPriceC = 9;
  42. cout << " how many tickets for class A of seats were sold? " << endl;
  43. cin >> numb1;
  44. cout << " how many tickets for class B of seats were sold? " << endl;
  45. cin >> numb2;
  46. cout << " how many tickets for class C of seats were sold? " << endl;
  47. cin >> numb3;
  48. //
  49. //Compute The Total Income
  50. total= unitPriceA* numb1+ unitPriceB* numb2+ unitPriceC * numb3;
  51. //
  52. //Output Result
  53. cout<< fixed<< setprecision(2)<< showpoint<< "The income generated from ticket sales is: $"<< total<< endl;
  54.  
  55. return 0;
  56. }
Success #stdin #stdout 0s 5320KB
stdin
34 34 78
stdout
 how many tickets for class A of seats were sold? 
 how many tickets for class B of seats were sold? 
 how many tickets for class C of seats were sold? 
The income generated from ticket sales is: $1620.00