fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. const int NUMSTORE = 5;
  7. int sales[NUMSTORE];
  8.  
  9. for ( int i = 0; i < NUMSTORE ; ++i){
  10. cout << "Enter today's sales for store " << (i + 1) << ": ";
  11. cin >> sales[i];
  12.  
  13. while ( sales [i] < 0 ){
  14.  
  15. cout << "Sales cannot be negative. Please enter again: ";
  16. cin >> sales[i];
  17. }
  18.  
  19. cout << "\nSALES BAR CHART\n(Each * = $100)\n";
  20.  
  21. for ( int i = 0; i < NUMSTORE; ++i ){
  22.  
  23. cout << "Store " << (i + 1) << ": ";
  24.  
  25. int numStars = sales[i] / 100;
  26. for ( int j = 0; j < numStars; ++j){
  27. cout << "* ";
  28. }
  29. cout << endl;
  30.  
  31.  
  32.  
  33.  
  34. }
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44. return 0;
  45. }
Success #stdin #stdout 0s 5284KB
stdin
-23
2222
stdout
Enter today's sales for store 1: Sales cannot be negative. Please enter again: 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: