Sep 22, 2013 at 7:50am UTC
#include <iostream>
#include <string>
#include <Windows.h>
#include <cmath>
using namespace std;
int main()
{
std::string input;
cout << "Choose arithmetic: Addition or Subtraction or Multiply or Divison " << endl;
cin >> input;
if(input == "Addition")
{
int first;
cout << "Enter the first number: " ;
cin >> first ;
int second;
cout << "Enter the second number: " ;
cin >> second ;
int sum = first + second;
cout << "The sum of these numbers is: " << sum << '\n' ;
Sleep(20000);
}
if(input == "Subtraction")
{
int first;
cout << "Enter the first number: " ;
cin >> first ;
int second;
cout << "Enter the second number: " ;
cin >> second ;
int diff = first - second;
cout << "The difference of these numbers is: " << diff << '\n' ;
Sleep(20000);
}
if(input=="Multipy")
{
int first;
cout << "Enter the first number: " ;
cin >> first;
int second;
cout << "Enter the second number: ";
cin >> second;
int diff = first * second;
cout << "The difference of these numbers is: " << diff << '\n' ;
Sleep(200000);
}
if(input=="Divison")
{
int first;
cout << "Enter the first number: " ;
cin >> first;
int second;
cout << "Enter the second number: ";
cin >> second;
int d = first / second;
cout << "The difference of these numbers is: " << d << endl;
Sleep(20000);
}
}
Sep 22, 2013 at 1:55pm UTC
ehh... i'm not gonna read that, please choose the source code format.
Sep 22, 2013 at 4:39pm UTC
Please use code tags: http://www.cplusplus.com/articles/jEywvCM9/
I don't see any problems right off, except
Since you have already done: using namespace std;
, then this line:
std::string input;
should be:
string input;
Sep 22, 2013 at 6:51pm UTC
I would modify this part
1 2 3
std::string input;
cout << "Choose arithmetic: Addition or Subtraction or Multiply or Divison " << endl;
cin >> input;
by this other
1 2 3
string input;
cout << "Choose arithmetic: Addition or Subtraction or Multiply or Divison " << endl;
getline(cin, input);
as you use it, erase
#include<cmath>
Last edited on Sep 22, 2013 at 6:54pm UTC