Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
10-14-2012, 10:10 PM #1
- Join Date
- Oct 2012
- Thanked 0 Times in 0 Posts
Loops validation not woorking - help
I'm trying to do a nested if inside a loop. The user has to enter a period between 5, 10, 15, 20, 25 years. Each year has a different rate and if the user enter a number that is not within these numbers the question is ask again.
The program runs good but the nested do-while loop is not working. If you see the condition of the while then you can see that it have to be a validation and if it is not in the range of those numbers it has to ask the questions again. And if you type 0 it ends the progam. The validation it's not working and I don't not why.
I alredy tried to change the && for ||
public class ACMEMORTGAGE
public static void main (String args )
double principal, rate=0;
Scanner key=new Scanner(System.in);
DecimalFormat decimalPlaces=new DecimalFormat("$0.00");
System.out.print("Enter principal amount (0 to end program):");
System.out.print("Enter mortgage amortization (1, 2, 3, 5, 10.):");
else if (mortgageTerm==2)
else if (mortgageTerm==3)
else if (mortgageTerm==5)
else if (mortgageTerm==10)
} while (mortgageTerm==1 && mortgageTerm==2 && mortgageTerm==3 && mortgageTerm==5 && mortgageTerm==10);