So this is my first post and i know it might seem dumb but I need to ask someone. I'm trying to write a program just to run in CMD and do a simple "what action would you like to perform?" and then jump to the function and perform it. See i can write the functions pretty easily, but my "if" statement seems to not actually compute when i have more than 2 options...works fine if its just 2 though?
-please don't flame me for using system() calls
-don't laugh at me too hard
#include<iostream>
#include<conio.h>
usingnamespace std;
//problems not here
int addition()
{
double a1;
double a2;
system("CLS");
cout << "This will add two numbers\n";
cout << "Please enter the first number:";
cin >> a1;
cout << "Please enter the second numeber:";
cin >> a2;
double adding= (a1 + a2);
cout << "The sum is ";
cout << adding;
cout << endl;
system("pause");
return 0;
}
//or here
int subtraction()
{
cout << "sup";
}
//not here either keep going down
int division()
{
double d1;
double d2;
system("CLS");
cout << "This will find the mean of two numbers\n";
cout << "Please enter the first number:";
cin >> d1;
cout << "Please enter the second numeber:";
cin >> d2;
double division= (d1/d2);
cout << "the mean is ";
cout << division;
cout << endl;
system("pause");
return 0;
}
//problem is here
int main()
{
string s1;
cout << "What math operation would you like to perform?\n";
cout << "Type addition, subtraction, or division\n";
cin >> s1;
if(s1=="Division", "division")
{
return division();
}
if(s1=="Addition", "addition")
{
return addition();
}
if(s1== "Subtraction", "subtraction")
{
return subtraction();
}
}
wow you made me look dumb, ill close this out in a second but, so just for the reference putting stuff like (x,y,z) only works for variables then? not like a list of things that it could be?
The associativity of comma operator is left to right. Your expression first evaluate left expression i.e. (s1 == "ABC"), and then 2nd which is a true value.