Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <sstream>
- using namespace std;
- int v1 = 0, v2 = 0, vFinal = 0;
- string op1, c;
- stringstream theOne;
- int main(){
- v1 = 0;
- v2 = 0;
- op1 = "";
- cout << "Info: 'C' to clear, 'X' to turn off \n Input the first number! \n" << endl;
- getline(cin, c);
- if(c == "C"){
- main();
- }else if(c == "X"){
- return 0;
- }else{
- stringstream(c) >> v1;
- }
- cout << "Info: 'C' to clear, 'X' to turn off \n Input the second number! \n" << endl;
- getline(cin, c);
- if(c == "C"){
- main();
- }else if(c == "X"){
- return 0;
- }else{
- stringstream(c) >> v2;
- }
- cout << "Info: 'C' to clear, 'X' to turn off \n Input the operation! \n" << endl;
- getline(cin, c);
- if(c == "C"){
- main();
- }else if(c == "X"){
- return 0;
- }else{
- op1 = c;
- }
- if(op1 == "*"){
- vFinal = v1*v2;
- cout << "The product of those numbers is " << vFinal << "\n \n" << endl;
- main();
- }else if(op1 == "/"){
- vFinal = v1/v2;
- cout << "The quotient of those numbers is " << vFinal << "\n \n" << endl;
- main();
- }else if(op1 == "+"){
- vFinal = v1+v2;
- cout << "The sum of those numbers is " << vFinal << "\n \n" << endl;
- main();
- }else if(op1 == "-"){
- vFinal = v1-v2;
- cout << "The difference of those numbers is " << vFinal << "\n \n" << endl;
- main();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement