Advertisement
Guest User

Calculator

a guest
Aug 20th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5.     double a,b,x;
  6.     std::cout << "a = ";
  7.     std::cin >> a;
  8.     std::cout << "b = ";
  9.     std::cin >> b;
  10.     std::cout << "What do you wanna do?:\n"
  11.     << "[1]Adding\n"
  12.     << "[2]Substraction\n"
  13.     << "[3]Multiplication\n"
  14.     << "[4]Divison\n"
  15.     << "[5]Equalization\n";
  16.     std::cin >> x;
  17.  
  18.     if (x == 1){
  19.         system("cls");
  20.         std::cout << a+b;
  21.     }
  22.     else if (x == 2){
  23.         system("cls");
  24.         std::cout << a-b;
  25.     }
  26.     else if (x == 3){
  27.         system("cls");
  28.         std::cout << a*b;
  29.     }
  30.     else if (x == 4){
  31.         system("cls");
  32.         std::cout << a/b;
  33.     }
  34.  
  35.     else if (x == 5){
  36.         if (a>b){
  37.             system("cls");
  38.             std::cout << "Number A is greater than B, difference between them is: "<< a-b;
  39.         }
  40.         else if (a<b){
  41.             system("cls");
  42.             std::cout << "Number B is greater than A, difference between them is: "<< b-a;
  43.         }
  44.         else if (a==b){
  45.             system("cls");
  46.             std::cout << "Numbers are equal";
  47.         }
  48.     }
  49.  
  50.  
  51.  
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement