Conditional Expression

I'm getting the error C4700: uninitialized local variable 'amountOfLoan' used.

- I am trying to add a conditional expression to the code below. I am getting the error above.

#include "stdafx.h"
#include <string>
#include <iostream>

using namespace std;

void main ()
{
cout << "Welcome to the Loan Payment Calculator\n\n";

string name;
string loanOption;
double interestRate, amountOfLoan, interest;
int lengthOfLoan;



//input
cout << "What is your name?";
cin >> name;
cout << "Hi "<<name<<" today, would you like to solve for monthly payments, loan amount, length of loan, or interest rate?";
cin >> loanOption;


if (loanOption == "interest rate")
{
cout << "What is your interest rate?";
cin >> interestRate;
cout << "What is the term of your loan?";
cin >> lengthOfLoan;
}

//calulations
interestRate = interestRate / 100;
interest = amountOfLoan * interestRate * lengthOfLoan;


//output
cout << "Your interest rate is: "<<interest<<endl;




system("pause");

}
well i dont see where you initialized amountOfLoan. you never assigned it any number
Topic archived. No new replies allowed.