Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- #include <iostream>
- #include <iomanip>
- #include <limits>
- void asterGraph();
- int main()
- {
- //menu function, 1 does operation, 2 quits, all other entries redirect back to menu
- double usrChoice = 0;
- while (usrChoice != 2)
- {
- //Ask user what they would like to do
- cout << "What would you like to do?: \n";
- cout << "1. Generate sales graph?\n";
- cout << "2. Quit\n";
- //get users choice
- cin >> usrChoice;
- if (usrChoice == 1)
- asterGraph();
- if (usrChoice > 2 || usrChoice < 1)
- cout << "Please enter a 1 or 2\n";
- }
- return 0;
- }
- void asterGraph()
- {
- //function for generating graphs using asterisks as characters
- int strOne, strTwo, strThree, graphOne, graphTwo, graphThree;
- //string asterOne, asterTwo, asterThree;
- cout << "what was the total sale for store one?\n";
- cin >> strOne;
- cout << "what was the total sale for store two?\n";
- cin >> strTwo;
- cout << "what was the total sale for store three?\n";
- cin >> strThree;
- //modulus is used to determine the number asterisks to display
- graphOne = (strOne / 100);
- graphTwo = (strTwo / 100);
- graphThree = (strThree / 100);
- string asterOne(graphOne, '*');
- string asterTwo(graphTwo, '*');
- string asterThree(graphThree, '*');
- //output tests
- cout << "test" << strOne << strTwo << strThree; "\n";
- cout << "test" << graphOne << graphTwo << graphThree; "\n";
- //asterisk bar graphs
- cout << asterOne; "\n";
- cout << asterTwo; "\n";
- cout << asterThree; "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement