Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Program4LeeBell.cpp : Defines the entry point for the console application.
- // lee bell 10/21/17
- #include "stdafx.h"
- #include <iostream>
- #include <cstdlib>
- #include <time.h>
- using namespace std;
- int main()
- {
- int x;
- int y;
- int response;
- cout << "Please enter 1 for Addition" << endl;
- cout << "Please enter 2 for Subtraction" << endl;
- cout << "Please enter 3 for Multiplication" << endl;
- cout << "Please enter 4 for Random Problems" << endl;
- cout << "Please enter - 1 to quit" << endl;
- cin >> response;
- while (response >= 1 && response <= 4)
- {
- switch (response)
- case 1:
- { x = rand() % 100;
- y = rand() % 100;
- cout << "How much is " << x << " plus " << y << " (-1 to end)" << endl;
- cin >> response;
- while (response != -1 && response != x + y)
- {
- cout << "No. Please try again." << endl << "? ";
- cin >> response;
- }
- if (response == x + y)
- cout << "Very good!" << endl << endl;
- }
- cout << "That's all for now. Bye." << endl;
- break;
- switch (response)
- case 2:
- {
- x = rand() % 100;
- y = rand() % 100;
- cout << "How much is " << x << " mius " << y << " ( -1 to end) " << endl;
- cin >> response;
- while (response != -1 && response != x - y)
- {
- cout << "No. Please try again." << endl << "? ";
- cin >> response;
- }
- if (response == x - y)
- cout << "Very good!" << endl << endl;
- }
- cout << "That's all for now. Bye." << endl;
- switch (response)
- case 3:
- {
- x = rand() % 100;
- y = rand() % 100;
- cout << " How much is " << x << " times " << y << " (-1 to end)" << endl;
- cin >> response;
- while (response != -1 && response != x * y)
- {
- cout << "No. Please try again." << endl << "? ";
- cin >> response;
- }
- if (response == x * y)
- cout << "Very good!" << endl << endl;
- }
- cout << "That's all for now. Bye." << endl;
- break;
- switch (response)
- case 4:
- {
- x = { 1 + rand() % 3 };
- y = { 1 + rand() % 3 };
- cout << "How much is " << x << " " << endl;
- while (response != -1 && response != x * y)
- {
- cout << "No. Please try again." << endl << "? ";
- cin >> response;
- }
- if (response == x * y)
- cout << "Very good!" << endl << endl;
- }
- cout << "That's all for now. Bye." << endl;
- }
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement