Hello,
this is a homework assignment, but it has already been turned in. I can't figure out why it does not produce any output. The code compiles fine, but when I run it all I get is "press any key to continue." This tells me the program ran, but my output isn't.
I've tried moving things around, but if I move my println statements to main, I get errors about a non-static value in a static method, so I'm stumped.
Can anyone give me a shove in the right direction towards fixing this thing? I want to learn what I did wrong so I can fix it and move forward on my next assignment.
Thanks!
Here's the code:
import java.io.PrintStream; public class MortgageCalc { private double loanAmount=0; private int years=0; private double interestRate=0; public double monthPay=0; public MortgageCalc (double loanAmount, int years, double interestRate) { this.loanAmount = loanAmount; // set the variables this.years = years; this.interestRate = interestRate; } public double calculations() { monthPay= ((loanAmount*(interestRate/12)) / (1 - 1 /Math.pow((1 + interestRate*12), years)));// calculation for monthly payment return monthPay; } public void display() { System.out.println("Mortgage Payment Calculator"); // should print out the title, but doesn't System.out.println("The amount of the loan $200,000"); // should print out the loan amount, but doesn't System.out.println("The term of the loan is 30 years"); // should print out the loan term, but doesn't System.out.println("The interest rate of the loan is 5.75%"); //should print out the loan rate, but doesn't System.out.println(); // should leave a blank line, but doesn't System.out.println("The monthly payment is: $" + monthPay ); //should print out the monthly payment, but doesn't System.out.println();// should leave a blank line, but doesn't } public static void main(String[] args) { MortgageCalc mortgageCalc = new MortgageCalc(200000,30,0.0575);// create the values for the calculation } }