For some reason this while loop executes regardless of whether the condition is true or false.I even changed the condition to something very simple like (payment < 5) then made sure i entered 25 at the right time and it still loops.
Anyone have any idea what mihgt be the issue? thanks
#include <iostream>
#include "header.h"
usingnamespace std;
void input (float & loanAmount, float & yearlyRate , float & payment, float & monthlyRate, int & desiredYears)
{
cout << "Please enter the loan amount, the yearly interest rate, the desired payment, and number of years you hope to take to repay the whole loan." << endl;
cin >> loanAmount >> yearlyRate >> payment >> desiredYears;
monthlyRate = ((yearlyRate / 12.0) * .01);
while (payment < (loanAmount * monthlyRate)); //minimum payment validation loop.
{
cout << "minimum payment not met, you will never be able to repay the loan!" << endl;
cout << "please enter a higher amount:" << endl;
input (loanAmount, yearlyRate , payment, monthlyRate, desiredYears);
}
}