Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. #include <cstdlib>
  5. #include <ctime>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. char userSelection;
  11. int numForTable;
  12.  
  13. do
  14. {
  15. cout << "MENU" << endl
  16. << "a) Generate Multiplication Table" << endl
  17. << "q) Quit the program" << endl
  18. << "Please make a selection: ";
  19. cin >> userSelection;
  20.  
  21. if (userSelection == 'a')
  22. {
  23. cout << "Please enter a number for your multiplication table: " << endl;
  24. cin >> numForTable;
  25.  
  26. while (numForTable < 1 || numForTable > 10)
  27. {
  28. cout << "Please enter a number between 1 & 10." << endl;
  29. cin >> numForTable;
  30. }
  31.  
  32. cout << "n"
  33. << "MULTIPLICATION TABLE: " << numForTable << "'s" << endl
  34. << "n";
  35.  
  36. for (int row = 1; row < numForTable; row++)
  37. {
  38. cout << setw(2) << row << "|";
  39.  
  40. for (int col = 1; col < numForTable; col++)
  41. {
  42. cout << setw(3) << row * col << "|";
  43. }
  44. }
  45.  
  46. }
  47.  
  48. else if (userSelection != 'q')
  49. {
  50. cout << "Invalid Selectionn" << endl;
  51. }
  52.  
  53. else if (userSelection == 'q')
  54. {
  55. cout << " You have chosen to quit the program. Thank you for using!" << endl;
  56. }
  57. }
  58.  
  59. while (userSelection != 'q');
  60.  
  61. system("PAUSE");
  62. return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement