What I'm trying to do is say the user types in -100000 for a loan amount
or "two" for the rate. I'm trying to give them an error message and put them back into putting in the loan amount or rate.
And if they enter positive information i'd ask them if they would like to calculate again. if they choose Y then they go back into the loop. if they choose n then i break it. I was wondering how do I do this, and would it be a if else loop or a combination of both if do and while loops?
Also I am very new at Java.. It would help if you guys typed out some of the code or typed an example of it so I at least had guidelines to follow.
Any help would be appreciated!
Basically I have this code:
package monthlypayment3a; import java.util.Scanner; public class Monthlypayment3a { private static double monthlypay1; public static void main(String[] args) { Scanner in = new Scanner(System.in); double months = 1; int loan; int numyears; double rate; System.out.print("Enter Loan Amount: "); loan = in.nextInt(); System.out.print("Enter Rate: "); rate = in.nextDouble(); System.out.print("Enter number of years: "); numyears = in.nextInt(); double calc1 = loan * rate; double calc2 = Math.pow(1 + rate, months); double calc3 = Math.pow(1 + rate, months)-1; double calc4 = calc1 / calc2; monthlypay1 = calc4 / calc3; System.out.print("The Monthly Payment is: $ " + monthlypay1); } }