Advertisement
DRAWNBOX

1337 Calculator

Jun 17th, 2015
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <stdlib.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     float input1;
  10.     float input2;
  11.     int function;
  12.     cout << "1 is multiply, 2 is addication, 3 is subtraction, 4 is division" << endl;
  13.     cin >> function;
  14.     if (function == 1)
  15.     {
  16.         cout << "OK, multiplying" << endl;
  17.         cout << "Enter your numbers" << endl;
  18.         cin >> input1 >> input2;
  19.         cout << "The answer is " << input1*input2 << endl;
  20.     }
  21.     else if (function == 2){
  22.         cout << "OK, adding" << endl;
  23.         cout << "Enter your numbers" << endl;
  24.         cin >> input1 >> input2;
  25.         cout << "The answer is " << input1 + input2 << endl;
  26.     }
  27.     else if (function == 3){
  28.         cout << "OK, subtracting" << endl;
  29.         cout << "Enter your numbers" << endl;
  30.         cin >> input1 >> input2;
  31.         cout << "The answer is " << input1 - input2 << endl;
  32.         }
  33.     else if (function == 4){
  34.         cout << "OK, dividing" << endl;
  35.         cout << "Enter your numbers" << endl;
  36.         cin >> input1 >> input2;
  37.         if (input2 == 0)
  38.         {
  39.             cout << "You're a noob, you cant divide by 0" << endl;
  40.         }
  41.         else if (input2 > 0)
  42.         {
  43.             cout << "The answer is " << input1 / input2 << endl;
  44.  
  45.         }
  46.     }
  47.         system("PAUSE");
  48.         return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement