loop executes regardless of conditions validity.

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


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include "header.h"
using namespace 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);
         }
       
         
         
         
}  
That semi colon at the end of your while statement might be doing it. I didn't even think that would execute.
bingo. Thanks a lot
Topic archived. No new replies allowed.