I tried to make a very simple calculator. It works as such :
Open the file...
Hit [ENTER]....
Type in one (1) number
[Enter]
Type in addition sign : +
[enter]
type in another number
[enter]
the result....wrong
Anyway, here is the code...any suggestions?
Code:
#include <iostream>
using namespace std;
int main () {
int first;
int second;
int answer;
char sign;
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
cout<<"~~~~ Calculator ~~~~\n";
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
cin>>first;
cin>>sign;
cin>>second;
if (sign=='+') {
answer = first + second;
cout<<answer;
}
if (sign=='-') {
answer = first - second;
cout<<answer;
}
if (sign=='*') {
answer = first * second;
cout<<answer;
}
if (sign='/') {
answer = first / second;
cout<<answer;
}
cin.get();
cin.get();
return 0;
}
Thanks so much!