Ok, i am having a problem with my if/else statements and i can't figure out what it is.
I have a cin statement asking for an unknown variable, but no matter what i enter it always does the first and only if statement, then ends the program.
#include<iostream>
#include<math.h>
#include<iomanip>
usingnamespace std;
void main()
{
double P1, r1, t1, e1, total1;
char unknown, var1, var2, var3, var4;
e1=2.718281828459045;
var1='T';
var2='P';
var3='r';
var4='t';
cout<<"Which variable is unknown in the formula, \"total = Pe^(rt)\" ? e is given.\n\n\n\n";
cout<<" Equation variable | What you should enter\n";
cout<<" | (Case sensitive) \n";
cout<<" -----------------------------------------\n";
cout<<" total | T \n";
cout<<" P | P \n";
cout<<" r | r \n";
cout<<" t | t \n\n\n";
cout<<"The unknown variable is: ";
cin>>unknown;
if (unknown == var1 /*total*/)
{
cout<<"\nPlease enter P.\n";
cin>>P1;
cout<<"\nPlease enter r.\n";
cin>>r1;
cout<<"\nPlease enter t.\n";
cin>>t1;
total1=((P1)*(pow(double(e1), double(r1*t1))));
cout<<fixed<<showpoint<<setprecision(2);
cout<<"\nThe total must equal to "<<total1<<"\n\n";
}
elseif (unknown == var2 /*P*/)
{
cout<<"\nPlease enter total.";
cin>>total1;
cout<<"\nPlease enter r.";
cin>>r1;
cout<<"\nPlease enter t.";
cin>>t1;
P1=((pow(double(e1), double(r1*t1))*100)/total1);
cout<<fixed<<showpoint<<setprecision(2);
cout<<"\nThen P must equal to "<<P1<<endl;
}
elseif (unknown == var3 /*r*/)
{
cout<<"\nPlease enter total.";
cin>>total1;
cout<<"\nPlease enter P.";
cin>>P1;
cout<<"\nPlease enter t.";
cin>>t1;
r1=((log(total1))/3);
cout<<fixed<<showpoint<<setprecision(2);
cout<<"\nThen r must equal to "<<r1<<endl;
}
elseif (unknown == var4 /*t*/)
{
cout<<"\nPlease enter total.";
cin>>total1;
cout<<"\nPlease enter P.";
cin>>P1;
cout<<"\nPlease enter r.";
cin>>r1;
t1=((log(total1))/2);
cout<<fixed<<showpoint<<setprecision(2);
cout<<"\nThen t must equal to "<<t1<<endl;
}
}
Actually disregard that last post... it turns out Moschops was correct, and i needed to create a new project in MSV in order for it to recognize the changes.