#include <iostream>
usingnamespace std;
int main()
{cout <<"Please press, \nm for multiplication, \nd for division, \ns for sutraction or \na for addition \n";
//Mutiplication
if (cin == "m") {
double thisisanumber2;
double thisisanumber;
double thisisanumber3;
cout<<"Please enter a number ";
cin>> thisisanumber;
cin.ignore();
cout<<"Please enter another number ";
cin>> thisisanumber2;
cin.ignore();
thisisanumber3 = thisisanumber * thisisanumber2;
cout<<""<< thisisanumber <<" Times "<< thisisanumber2 <<" Is "<< thisisanumber3 <<"\n";
cin.get();}
//Division
if (cin == "d"){
double thisisanumber2;
double thisisanumber;
double thisisanumber3;
cout<<"Please enter a number ";
cin>> thisisanumber;
cin.ignore();
cout<<"Please enter another number ";
cin>> thisisanumber2;
cin.ignore();
thisisanumber3 = thisisanumber / thisisanumber2;
cout<<""<< thisisanumber <<" Divided by "<< thisisanumber2 <<" Is "<< thisisanumber3 <<"\n";
cin.get();}
//Subtraction
if(cin == "s"){
double thisisanumber2;
double thisisanumber;
double thisisanumber3;
cout<<"Please enter a number ";
cin>> thisisanumber;
cin.ignore();
cout<<"Please enter another number ";
cin>> thisisanumber2;
cin.ignore();
thisisanumber3 = thisisanumber - thisisanumber2;
cout<<""<< thisisanumber <<" Minus "<< thisisanumber2 <<" Is "<< thisisanumber3 <<"\n";
cin.get();}
//Addition
if(cin == "a"){
double thisisanumber2;
double thisisanumber;
double thisisanumber3;
cout<<"Please enter a number ";
cin>> thisisanumber;
cin.ignore();
cout<<"Please enter another number ";
cin>> thisisanumber2;
cin.ignore();
thisisanumber3 = thisisanumber + thisisanumber2;
cout<<""<< thisisanumber <<" Plus "<< thisisanumber2 <<" Is "<< thisisanumber3 <<"\n";
cin.get();}
}
Very sorry if it's a simple error, but i'm a complete noob at C++.
You are attempting to compare the object cin with the object
"a"
cin is an object of type istream.
"a" is a string literal.
It makes no sense whatsoever to compare an object of type istream with a string literal, and unsurprisingly the compiler has no idea what to do with it.
You're using cin wrongly. Use cin to get something from the keyboard, like this:
1 2
string userInput;
cin >> userInput;
and then compare the string object userInput with things.