import java.util.Scanner; // import scanner public class Loan { static Scanner input = new Scanner(System.in); // create scanner object usable in all methods public static void main(String[] args) { // Declarations int cont = 1; double loanAmount = 1; double interest = 1.1; double numberYears = 1; double monthlyInterest = interest/1200; //endDeclarations System.out.println("Welcome to the loan Calculator. I will help you calculate the monthy payments on a loan"); //welcome statement System.out.print("Would you like to calculate loan payments now? Please enter 1 for Yes anything else for No: "); //loop variable input cont = input.nextInt(); while(cont == 1){ // begin while loop //begin collecting data for variables System.out.print("Please enter the loan amount in dollars and cents. Example: $1500.75:$ "); loanAmount = input.nextDouble(); System.out.print("Please enter the interest rate. Example: 5.7%:% "); interest = input.nextDouble(); System.out.print("Please enter the number of years the loan will be for. Example: 15: "); numberYears = input.nextInt(); double monthlyRepayment = loanAmount* monthlyInterest/(1-(Math.pow(1/ (1+monthlyInterest), numberYears*12))); System.out.println("The Monthly Payment: $" + (int) (monthlyRepayment * 100 /100.0 )); System.out.println("Would you like to calculate another Loan? Please enter 1 for Yes: "); cont = input.nextInt(); } // endwhile System.out.println("Thanks for using the Loan Calculator!"); } }
I think my Math calculation is correct now. I just need help if anyone could with getting it into separate methods. I do not know why I am updating this since no one seems to want to help me anyhow. I just holding out hope.