fork download
  1. //Jeremy Huang CS1A Chapter 5, P. 297, #17
  2. //
  3. /**************************************************************
  4.  *
  5.  * CREATE BAR CHART FOR SALES
  6.  * ____________________________________________________________
  7.  * This program takes user input sales generated at 5 different
  8.  * stores and creates a bar chart through "*" with each star
  9.  * representing $100.
  10.  * ____________________________________________________________
  11.  * INPUT
  12.  * sales1 : amount of sales generated for store 1
  13.  * sales2 : amount of sales generated for store 2
  14.  * sales3 : amount of sales generated for store 3
  15.  * sales4 : amount of sales generated for store 4
  16.  * sales5 : amount of sales generated for store 5
  17.  *
  18.  * OUTPUT
  19.  * N/A :cout outputs which will freeze or boil
  20.  *
  21.  **************************************************************/
  22.  
  23. #include <iostream>
  24. using namespace std;
  25.  
  26. int main() {
  27. //Amount of sales generated for store x
  28. double sales1, sales2, sales3, sales4, sales5;
  29.  
  30. //User Input
  31. cout<<"Enter today's sales for store 1: "<<endl;
  32. cin>>sales1;
  33. cout<<"Enter today's sales for store 2: "<<endl;
  34. cin>>sales2;
  35. cout<<"Enter today's sales for store 3: "<<endl;
  36. cin>>sales3;
  37. cout<<"Enter today's sales for store 4: "<<endl;
  38. cin>>sales4;
  39. cout<<"Enter today's sales for store 5: "<<endl;
  40. cin>>sales5;
  41.  
  42. //Output Result
  43. cout<<endl;
  44. cout<<"SALES BAR CHART"<<endl;
  45. cout<< "(Each * = $100)"<<endl;
  46.  
  47. cout << "Store 1: ";
  48. for (int i = 0; i < sales1 / 100; i++) {
  49. cout << "*";
  50. }
  51. cout << endl;
  52.  
  53. cout << "Store 2: ";
  54. for (int i = 0; i < sales2 / 100; i++) {
  55. cout << "*";
  56. }
  57. cout << endl;
  58.  
  59. cout << "Store 3: ";
  60. for (int i = 0; i < sales3 / 100; i++) {
  61. cout << "*";
  62. }
  63. cout << endl;
  64.  
  65. cout << "Store 4: ";
  66. for (int i = 0; i < sales4 / 100; i++) {
  67. cout << "*";
  68. }
  69. cout << endl;
  70.  
  71. cout << "Store 5: ";
  72. for (int i = 0; i < sales5 / 100; i++) {
  73. cout << "*";
  74. }
  75. cout << endl;
  76.  
  77. return 0;
  78. }
Success #stdin #stdout 0.01s 5288KB
stdin
1000
1200
1800
800
1900
stdout
Enter today's sales for store 1: 
Enter today's sales for store 2: 
Enter today's sales for store 3: 
Enter today's sales for store 4: 
Enter today's sales for store 5: 

SALES BAR CHART
(Each * = $100)
Store 1: **********
Store 2: ************
Store 3: ******************
Store 4: ********
Store 5: *******************