Well that and I just realized I was diving by 0.. "(1-1 / math.pow(1 + rate, months));" So I fixed the coding in the math to
monthlypay1 = loanamount * rate / (Math.pow(1 + rate, months)) / (Math.pow(1 + rate, months)-1);
. Thanks for pointing that out.
--- Update ---
This is my new code.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package monthypayment2;
import java.util.Scanner;
/**
*
* @author Aj Miles
*/
public class Monthypayment2 {
private static double monthlypay1;
private static String choice;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double months = 0;
double numyears;
double loanamount;
double rate;
//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();
//calculate
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.println("You need to enter positive numerical data!");
}
Else {
System.out.println("Would you like to calculate again?: (Y/N)"); }
}
}
}
Was seeing if anyone can help me out with the boolean statement.
I've looked at a couple of examples of boolean statements but wasn't very helpful. (
how to use boolean data type in Java)
Basically what i'm trying to do is if the user enters' say a negative number after everything is done it will tell the user
to enter positive numerical data. If he enters a positive number it will ask him if he wants to continue calculations again?