Advertisement
Guest User

simple calculator

a guest
Nov 13th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int main() {
  5.         string operand;
  6.         cout << "Enter Operator, eg: +, -, *, or /" << endl;
  7.         cin >> operand;
  8.         if (operand == "+") {
  9.             float input1;
  10.             float input2;
  11.             cout << "Enter input 1." << endl;
  12.             cin >> input1;
  13.             cout << "Alright, enter input 2." << endl;
  14.             cin >> input2;
  15.             cout << "The sum is " << input1 + input2 << endl;
  16.             return 0;
  17.         } else if (operand == "-") {
  18.             float input1;
  19.             float input2;
  20.             cout << "Enter input 1." << endl;
  21.             cin >> input1;
  22.             cout << "Alright, enter input 2." << endl;
  23.             cin >> input2;
  24.             cout << "The sum is " << input1 - input2 << endl;
  25.             return 0;
  26.         } else if (operand == "*") {
  27.             float input1;
  28.             float input2;
  29.             cout << "Enter input 1." << endl;
  30.             cin >> input1;
  31.             cout << "Alright, enter input 2." << endl;
  32.             cin >> input2;
  33.             cout << "The sum is " << input1 * input2 << endl;
  34.             return 0;
  35.         } else if (operand == "/") {
  36.             float input1;
  37.             float input2;
  38.             cout << "Enter input 1." << endl;
  39.             cin >> input1;
  40.             cout << "Alright, enter input 2." << endl;
  41.             cin >> input2;
  42.             cout << "The sum is " << input1 / input2 << endl;
  43.             return 0;
  44.         }
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement