Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main()
- {
- char userSelection;
- int numForTable;
- do
- {
- cout << "MENU" << endl
- << "a) Generate Multiplication Table" << endl
- << "q) Quit the program" << endl
- << "Please make a selection: ";
- cin >> userSelection;
- if (userSelection == 'a')
- {
- cout << "Please enter a number for your multiplication table: " << endl;
- cin >> numForTable;
- while (numForTable < 1 || numForTable > 10)
- {
- cout << "Please enter a number between 1 & 10." << endl;
- cin >> numForTable;
- }
- cout << "n"
- << "MULTIPLICATION TABLE: " << numForTable << "'s" << endl
- << "n";
- for (int row = 1; row < numForTable; row++)
- {
- cout << setw(2) << row << "|";
- for (int col = 1; col < numForTable; col++)
- {
- cout << setw(3) << row * col << "|";
- }
- }
- }
- else if (userSelection != 'q')
- {
- cout << "Invalid Selectionn" << endl;
- }
- else if (userSelection == 'q')
- {
- cout << " You have chosen to quit the program. Thank you for using!" << endl;
- }
- }
- while (userSelection != 'q');
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement