I had this question before but I am stuck on how to get it to output correctly. This is my assignment:
Write the program in Java (without a graphical user interface) and have it calculate the payment amount for 3 mortgage loans:

- 7 year at 5.35%
- 15 year at 5.5%
- 30 year at 5.75%

Use an array for the different loans. Display the mortgage payment amount for each loan.

Loan Amount: $200,000.00
Term: 7 Years
Interest Rate 5.35%
The monthly payment amount is $1167.15
Term: 15 Years
Interest Rate 5.5%
The monthly payment amount is $0.00
Term: 30 Years
Interest Rate 5.75%
The monthly payment amount is $0.00
360 year at 0.0575%:
1167.1457128870984
180 year at 0.055%:
1167.1457128870984
84 year at 0.0535%:
1167.1457128870984

What is it in particular that you are talking about - do you mean it is format of numbers 1167.1457128870984
with many decimals that you don't like, or you are talking abouyrt numbers themsaelves?

Still you need to explain do you want printed for many different variants or for one of them - that's
waht I mean by index - to select variant. If not
you want to print all of them and you don't need to read index

Loan Amount: $200000,00
Term: 30 Years Interest Rate: 5,75% The monthly payment amount is $1167,15
Term: 15 Years Interest Rate: 5,50% The monthly payment amount is $1634,17
Term: 7 Years Interest Rate: 5,35% The monthly payment amount is $2859,79

import java.io.IOException;public class GutierrezMortgages { //Method to Calculate Mortgage using the principal amount, the interest, and the term static int[] loanTerm = {360,180,84}; //*30 years, 15 years, 7 years static double loanInterest[] = {.0575, .0550, .0535}; //*5.75% interest rate(ir), 5.50% (ir), 5.35% (ir) static double loanAmount = 200000; //*$200,000 Loan public static double calculateMortgage (double loanAmount, double loanInterest, int loanTerm) { double myMortgage = (loanAmount*loanInterest/12)/(1-Math.pow(1+loanInterest/12, -loanTerm)); return myMortgage; } //Method to display the calculated mortgage public static void displayTheMortgages() { System.out.println(); System.out.printf("\t\tLoan Amount: $%.2f\n", loanAmount); for (int i = 0; i < loanTerm.length; i++) { System.out.printf("\t\tTerm: %d Years", loanTerm [i] / 12); System.out.printf("\t\tInterest Rate: %.2f%%", loanInterest[i] * 100); System.out.printf("\t\tThe monthly payment amount is $%.2f", calculateMortgage (loanAmount, loanInterest[i], loanTerm[i])); System.out.println(); } } public static void main(String[] args){ displayTheMortgages(); }}

If it is about many different variants - then each one should be calculated in the code:
I added index argument because I saw that you in fact calculate only one variant.
If you want to calculate for all cases it will also make
sense to make array out of myMortgage, myMortGagaOn2, myMortgageTwo - why not to have double myMortGage[3];
- it will simplify code

0

PapaDragonXAuthor Commented:

Thanks for your help. I wanted it to display the different variants all the calculations so what you mentioned is how I want it. I guess I am still trying to figure indexes and arrays and it is confusing to get them to all work together when you have a calculation.

Loan Amount: $200000.00 Term: 30 Years Interest Rate: 5.75% The monthly payment amount is $1167.15 Term: 15 Years Interest Rate: 5.50% The monthly payment amount is $1634.17 Term: 7 Years Interest Rate: 5.35% The monthly payment amount is $2859.79

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

What is it in particular that you are talking about - do you mean it is format of numbers 1167.1457128870984

with many decimals that you don't like, or you are talking abouyrt numbers themsaelves?