Program not handling properly when values are equal.

I am writing a program for my programming class. For one program we were to create an amortized loan program, and on one part we were to make it so that the user can't enter a payment lower than we calculate their minimum to be.

I have the program written, and it executes great.
I used a while loop to handle monthly payments that were to low, uses nested if/else. But for some reason the program can't handle if the calculated minimum payment is equal to the users input for their payment. It will keep outputting telling them there payment is to low.

I even tried adding in a separate else if statement just to handle when the minimum payment equals the entered monthly payment.


1
2
3
4
5
6
7
8
9
10
11
12
13
 while (true)
{
cout << "\nEnter monthly payment" << endl;
cin >> p;
	if (p>=mp) break;
		else
		{
		cout << "Your minimum payment has not been met.\n";
		cout << "Please input a payment of equal or greater value to " << mp << endl;
		continue;
		}
		
}


if the entered monthly payment happens to be equal to the calculated minimum payment, mp then the output is as follows...


Your minimum payment has not been met.
Please input a payment of equal or greater value to "mp"

Enter monthly payment


and so on and so fourth.
Last edited on
The type of p and mp is?
I believe you need three cases here: When mp is bigger than p(mp>p) when mp is smaller than p(mp<p) and when they are equal(mp=p)
I believe you need three cases here: When mp is bigger than p(mp>p) when mp is smaller than p(mp<p) and when they are equal(mp=p)


I tried that
I even tried adding in a separate else if statement just to handle when the minimum payment equals the entered monthly payment.

That's what I was meaning by that.


....and they are doubles
....and they are doubles


This is most likely the problem. Read: http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
Topic archived. No new replies allowed.