Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.33 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 <time.h>
  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.             { x = rand() % 100;
  35.             y = rand() % 100;
  36.             cout << "How much is " << x << " plus " << y << " (-1 to end)" << endl;
  37.             cin >> response;
  38.             while (response != -1 && response != x + y)
  39.             {
  40.                 cout << "No. Please try again." << endl << "? ";
  41.                 cin >> response;
  42.             }
  43.             if (response == x + y)
  44.                 cout << "Very good!" << endl << endl;
  45.             }
  46.             cout << "That's all for now. Bye." << endl;
  47.             break;
  48.         switch (response)
  49.         case 2:
  50.             {
  51.             x = rand() % 100;
  52.             y = rand() % 100;
  53.             cout << "How much is " << x << " mius " << y << " ( -1 to end) " << endl;
  54.             cin >> response;
  55.             while (response != -1 && response != x - y)
  56.             {
  57.                 cout << "No. Please try again." << endl << "? ";
  58.                 cin >> response;
  59.             }
  60.             if (response == x - y)
  61.                 cout << "Very good!" << endl << endl;
  62.             }
  63.             cout << "That's all for now. Bye." << endl;
  64.         switch (response)
  65.         case 3:
  66.             {
  67.             x = rand() % 100;
  68.             y = rand() % 100;
  69.             cout << " How much is " << x << " times " << y << " (-1 to end)" << endl;
  70.             cin >> response;
  71.             while (response != -1 && response != x * y)
  72.             {
  73.                 cout << "No. Please try again." << endl << "? ";
  74.                 cin >> response;
  75.             }
  76.             if (response == x * y)
  77.                 cout << "Very good!" << endl << endl;
  78.             }
  79.             cout << "That's all for now. Bye." << endl;
  80.             break;
  81.         switch (response)
  82.         case 4:
  83.             {
  84.             x = { 1 + rand() % 3 };
  85.             y = { 1 + rand() % 3 };
  86.             cout << "How much is " << x << " " << endl;
  87.  
  88.  
  89.         while (response != -1 && response != x * y)
  90.         {
  91.             cout << "No. Please try again." << endl << "? ";
  92.             cin >> response;
  93.         }
  94.         if (response == x * y)
  95.             cout << "Very good!" << endl << endl;
  96.     }
  97.     cout << "That's all for now. Bye." << endl;
  98. }
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.     system("PAUSE");
  109.     return 0;
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement