Advertisement
DRAWNBOX

!337'er Calculator

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