#include <iostream>
usingnamespace std;
int main()
{
double FirstNum, SecondNum, Output;
int FirstNumInt, SecondNumInt, OutputInt;
char oper;
char cont = 0;
cout <<"Enter two numbers"<<endl;
cin>>FirstNum;
cin>>SecondNum;
FirstNumInt = FirstNum;
SecondNumInt = SecondNum;
cout<<"Enter a mathmatical operator such as +, -, *, /, %, <, and >"<< endl;
cin>>oper;
if (oper == '+')
{
Output = FirstNum + SecondNum;
cout<<Output<<endl;
}
if (oper == '-')
{
Output = FirstNum - SecondNum;
cout<<Output<<endl;
}
if (oper == '*')
{
Output = FirstNum * SecondNum;
cout<<Output<<endl;
}
if (oper == '/')
{
Output = FirstNum / SecondNum;
cout<<Output<<endl;
}
if (oper == '%')
{
OutputInt = FirstNumInt % SecondNumInt;
cout<<OutputInt<<endl;
}
if (oper == '<')
{
if (FirstNum < SecondNum)
{
cout<<"True"<<endl;
}
else
{
cout<<"False"<<endl;
}
if (oper == '>')
{
if (FirstNum > SecondNum)
{
cout<<"True"<<endl;
}}
else{
cout<<"False"<<endl;
}
}}
Try something like that(removing if else and just using if and else).
This runs fine, however, I am sure it's not exactly what you need. Try tweaking this code into what you need.
All right, I am almost at the finish line. I hope you will all forgive me for my ignorance, this is the first real C++ program I have ever designed. I have this code.
Wait, never mind, that actually does work! I was entering N as a number. When entered as an operator it works. Not the most robust program I admit, but it works! Thank you all for your help on this.