Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. using namespace std;
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <limits>
  5.  
  6. void asterGraph();
  7.  
  8. int main()
  9. {
  10.     //menu function, 1 does operation, 2 quits, all other entries redirect back to menu
  11.     double usrChoice = 0;
  12.     while (usrChoice != 2)
  13.     {
  14.         //Ask user what they would like to do
  15.         cout << "What would you like to do?: \n";
  16.         cout << "1. Generate sales graph?\n";
  17.         cout << "2. Quit\n";
  18.         //get users choice
  19.         cin >> usrChoice;
  20.  
  21.         if (usrChoice == 1)
  22.             asterGraph();
  23.         if (usrChoice > 2 || usrChoice < 1)
  24.         cout << "Please enter a 1 or 2\n";
  25.  
  26.     }
  27.     return 0;
  28. }
  29.  
  30.  
  31. void asterGraph()
  32. {
  33.     //function for generating graphs using asterisks as characters
  34.     int strOne, strTwo, strThree, graphOne, graphTwo, graphThree;
  35.    
  36.     //string asterOne, asterTwo, asterThree;
  37.  
  38.         cout << "what was the total sale for store one?\n";
  39.         cin >> strOne;
  40.         cout << "what was the total sale for store two?\n";
  41.         cin >> strTwo;
  42.         cout << "what was the total sale for store three?\n";
  43.         cin >> strThree;
  44.  
  45.         //modulus is used to determine the number asterisks to display
  46.         graphOne = (strOne / 100);
  47.         graphTwo = (strTwo / 100);
  48.         graphThree = (strThree / 100);
  49.         string asterOne(graphOne, '*');
  50.         string asterTwo(graphTwo, '*');
  51.         string asterThree(graphThree, '*');
  52.  
  53.         //output tests
  54.         cout << "test" << strOne << strTwo << strThree; "\n";
  55.         cout << "test" << graphOne << graphTwo << graphThree; "\n";
  56.        
  57.         //asterisk bar graphs
  58.         cout << asterOne; "\n";
  59.         cout << asterTwo; "\n";
  60.         cout << asterThree; "\n";
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement