Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4.  
  5.     using namespace std;
  6.     int v1 = 0, v2 = 0, vFinal = 0;
  7.     string op1, c;
  8.     stringstream theOne;
  9.  
  10. int main(){
  11.         v1 = 0;
  12.         v2 = 0;
  13.         op1 = "";
  14.     cout << "Info: 'C' to clear, 'X' to turn off \n Input the first number! \n" << endl;
  15.         getline(cin, c);
  16.         if(c == "C"){
  17.             main();
  18.         }else if(c == "X"){
  19.             return 0;
  20.         }else{
  21.         stringstream(c) >> v1;
  22.         }
  23.  
  24.         cout << "Info: 'C' to clear, 'X' to turn off \n Input the second number! \n" << endl;
  25.         getline(cin, c);
  26.         if(c == "C"){
  27.             main();
  28.         }else if(c == "X"){
  29.            return 0;
  30.         }else{
  31.         stringstream(c) >> v2;
  32.         }
  33.  
  34.         cout << "Info: 'C' to clear, 'X' to turn off \n Input the operation! \n" << endl;
  35.         getline(cin, c);
  36.         if(c == "C"){
  37.             main();
  38.         }else if(c == "X"){
  39.             return 0;
  40.         }else{
  41.         op1 = c;
  42.         }
  43.  
  44. if(op1 == "*"){
  45.         vFinal = v1*v2;
  46.         cout << "The product of those numbers is " << vFinal << "\n \n" <<  endl;
  47.         main();
  48.  
  49. }else if(op1 == "/"){
  50.         vFinal = v1/v2;
  51.         cout << "The quotient of those numbers is " << vFinal << "\n \n" <<  endl;
  52.         main();
  53.  
  54. }else if(op1 == "+"){
  55.         vFinal = v1+v2;
  56.         cout << "The sum of those numbers is " << vFinal << "\n \n" <<  endl;
  57.         main();
  58.  
  59. }else if(op1 == "-"){
  60.         vFinal = v1-v2;
  61.         cout << "The difference of those numbers is " << vFinal << "\n \n" << endl;
  62.         main();
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement