public static void main(String[] args) { Scanner in = new Scanner(System.in); //format number and currency NumberFormat NF = NumberFormat.getCurrencyInstance(); NumberFormat NI = NumberFormat.getNumberInstance(); double months = 1; double numyears; double loanamount; double rate; //put while statement here //prompt loan amount System.out.print("Enter Loan Amount:"); loanamount = in.nextDouble(); //prompt rate System.out.print("Enter Rate:"); rate = in.nextDouble(); //prompt years System.out.print("Enter Number of Years:"); numyears = in.nextDouble(); //calculation monthly monthlypay1 = loanamount * rate / (Math.pow(1 + rate, months)) / (Math.pow(1 + rate, months)-1); System.out.println("The Monthly Payment is: $" + monthlypay1); if (monthlypay1 < 0) { System.out.print("You need to enter positive numerical data!");} else { System.out.print("Would you like to continue calculations(y/n)?"); } choice = in.next(); System.out.println(); n = False; if (choice.equals(n)) { } } }
Basically I am trying to loop this. I've tried adding a while statementI've also tried while n == true basically trying to make a while statement to loop the whole thing so that at the end if the user selects "Y" it will loop them back. If the user selects "N" it will break them out the loop. Please help.while (n.equals( n) {