Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.32 KB | None | 0 0
  1. // Program4LeeBell.cpp : Defines the entry point for the console application.
  2. // lee bell 10/21/17
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <cstdlib>
  7. #include <ctime>
  8. using namespace std;
  9.  
  10.  
  11. int main()
  12. {
  13.     int x;
  14.     int y;
  15.     int response;
  16.    
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.     cout << "Please enter 1 for Addition" << endl;
  24.     cout << "Please enter 2 for Subtraction" << endl;
  25.     cout << "Please enter 3 for Multiplication" << endl;
  26.     cout << "Please enter 4 for Random Problems" << endl;
  27.     cout << "Please enter - 1 to quit" << endl;
  28.     cin >> response;
  29.     while (response >= 1 && response <= 4)
  30.     {
  31.    
  32.         switch (response)
  33.             case 1:
  34.             {
  35.             srand(time(0));
  36.              x = rand() % 100;
  37.             y = rand() % 100;
  38.             cout << "How much is " << x << " plus " << y << endl;
  39.             cin >> response;
  40.             while (response != -1 && response != x + y)
  41.             {
  42.                 cout << "No. Please try again." << endl << "? ";
  43.                 cin >> response;
  44.             }
  45.             if (response == x + y)
  46.                 cout << "Very good!" << endl << endl;
  47.             }
  48.             cout << "That's all for now. Bye." << endl;
  49.             break;
  50.         switch (response)
  51.         case 2:
  52.             {
  53.             srand(time(0));
  54.             x = rand() % 100;
  55.             y = rand() % 100;
  56.             cout << "How much is " << x << " mius " << y << endl;
  57.             cin >> response;
  58.             while (response != -1 && response != x - y)
  59.             {
  60.                 cout << "No. Please try again." << endl << "? ";
  61.                 cin >> response;
  62.             }
  63.             if (response == x - y)
  64.                 cout << "Very good!" << endl << endl;
  65.             }
  66.             cout << "That's all for now. Bye." << endl;
  67.         switch (response)
  68.         case 3:
  69.             {
  70.             x = rand() % 100;
  71.             y = rand() % 100;
  72.             cout << " How much is " << x << " times " << y << endl;
  73.             cin >> response;
  74.             while (response != -1 && response != x * y)
  75.             {
  76.                 cout << "No. Please try again." << endl << "? ";
  77.                 cin >> response;
  78.             }
  79.             if (response == x * y)
  80.                 cout << "Very good!" << endl << endl;
  81.             }
  82.             cout << "That's all for now. Bye." << endl;
  83.             break;
  84.         switch (response)
  85.         case 4:
  86.             {
  87.             x = { 1 + rand() % 3 };
  88.             y = { 1 + rand() % 3 };
  89.             cout << "How much is " << x << " " << endl;
  90.  
  91.  
  92.         while (response != -1 && response != x * y)
  93.         {
  94.             cout << "No. Please try again." << endl << "? ";
  95.             cin >> response;
  96.         }
  97.         if (response == x * y)
  98.             cout << "Very good!" << endl << endl;
  99.     }
  100.     cout << "That's all for now. Bye." << endl;
  101. }
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.     system("PAUSE");
  112.     return 0;
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement