Help with program and number equalities (==)
Hello,
I am having trouble with some code that I am using. No matter what number I press in the following code when I run it, It always thinks that ( finoptype == 1 ):
Code:
{
float finoptype;
cout<<"\nWelcome to the finace calculator group. Currently the Math Master can calculate the total cost of a loan, or calculate the intrest money will earn in a savings account/CD in a period of time that you specify. Please choose either the loan calculator(1) or the savings interest calculator(2): ";
cin>> finoptype;
cin.ignore();
if ( finoptype = 1 ) {
float finloantot;
float finloaninttype;
float finloanlength;
cout<<"\nPlease enter the amount of money the loan will be for (Please no dollar signs): ";
cin>> finloantot;
cin.ignore();
cout<<"\nPlease enter the total length in years of the loan: ";
cin>> finloanlength;
cin.ignore();
cout<<"\nPlease select the loan interest rate type, either monthly(1) or yearly(2): ";
cin>> finloaninttype;
cin.ignore();
if ( finloaninttype == 1 ) {
float finloanintrate1;
float finloanyerrate1;
float finloantottot11;
float finloantottot12;
float finloantottot13;
cout<<"\nPlease enter loan monthly interest rate in decimal form (if using a percentage, move the decimal point back two places from the end of the percentage): ";
cin>> finloanintrate1;
cin.ignore();
finloanyerrate1 = finloanintrate1 * 12;
finloantottot11 = finloanyerrate1 * finloantot;
finloantottot12 = finloantottot11 * finloanlength;
finloantottot13 = finloantottot12 + finloantot;
cout<<"\nThe total cost of your loan is: "<< finloantottot13 <<" dollars.\n";
}
else if ( finloaninttype == 2 ) {
float finloanintrate2;
float finloantottot21;
float finloantottot22;
float finloantottot23;
cout<<"\nPlease enter loan yearly interest rate in decimal form (if using a percentage, move the decimal point back two places from the end of the percentage): ";
cin>> finloanintrate2;
cin.ignore();
finloantottot21 = finloanintrate2 * finloantot;
finloantottot22 = finloantottot21 * finloanlength;
finloantottot23 = finloantottot22 + finloantot;
cout<<"\nThe total cost of your loan is: "<< finloantottot23 <<" dollars.\n";
}
else {
cout<<"That is not a valid option. Please run the program again and enter a valid option.";
}
}
Any help that you can give me would be great.