Advertisement
Guest User

Basic Calculator

a guest
Oct 24th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. int main() {
  5.     string i;
  6.     string newString ="Commands: \n ;calculator \n What would you like me to do, sir?: ";
  7.     cout<<newString;
  8.     cin>>i;
  9.     if (i == ";calculator"){
  10.         int a,b;
  11.         newString = "\n Multiplication \n Division \n Addition \n Subtraction";
  12.         cout<<newString;
  13.         newString = "\n Choose one: ";
  14.         cout<<newString;
  15.         cin>>i;
  16.         if (i == "Multiplication") {
  17.             newString = "Insert first number here: ";
  18.             cout<<newString;
  19.             cin>>i;
  20.             a = stoi(i);
  21.             newString = "Insert second number here: ";
  22.             cout<<newString;
  23.             cin>>i;
  24.             b=stoi(i);
  25.             cout<<a*b;
  26.         }
  27.         else{
  28.             if (i == "Division") {
  29.             newString = "Insert dividend here: ";
  30.             cout<<newString;
  31.             cin>>i;
  32.             a = stoi(i);
  33.             newString = "Insert divisor here: ";
  34.             cout<<newString;
  35.             cin>>i;
  36.             b=stoi(i);
  37.             cout<<a/b;
  38.             }
  39.             else{
  40.                 if (i == "Subtraction") {
  41.                 newString = "Insert first number here: ";
  42.                 cout<<newString;
  43.                 cin>>i;
  44.                 a = stoi(i);
  45.                 newString = "Insert second number here: ";
  46.                 cout<<newString;
  47.                 cin>>i;
  48.                 b=stoi(i);
  49.                 cout<<a-b;
  50.                 }
  51.                 else{
  52.                     if (i == "Addition") {
  53.                         newString = "Insert first number here: ";
  54.                         cout<<newString;
  55.                         cin>>i;
  56.                         a = stoi(i);
  57.                         newString = "Insert second number here: ";
  58.                         cout<<newString;
  59.                         cin>>i;
  60.                         b=stoi(i);
  61.                         cout<<a+b;
  62.                     }  
  63.                 }  
  64.             }
  65.         }
  66.     }
  67.     else{
  68.         cout<<"Not a command!";
  69.         return 0;
  70.     }  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement