Jump to content

Faizura Fadzil

Learning
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

0 Normal

About Faizura Fadzil

  • Rank
    Ahli Baru
  • Birthday 10/05/1991

Profile Information

  • Gender
    Female
  1. Faizura Fadzil

    Coding Error

    salam kawan-2, tlg tgkkan coding ni . ada dua error . import java.io.*; import java.text.*; import java.text.DecimalFormat; public class WK5IA { public static void main(String[] args) throws IOException { // declare variables int loanAmt = 200000; // principal loan amount int[] loanTerm = {84, 180 ,360}; // loan term for 7 years, 15 years, and 30 years int loanYears; // indicates the loan term in years double[] intRate = {5.35, 5.50, 5.75}; // interest rates for 7 years, 15 years, and 30 years double newIntRate; // displays interest rate calculation double monthlyPay = 0; // displays monthly payment calculation DecimalFormat money = new DecimalFormat("$#,###.00"); // displays mortgage in decimal format DecimalFormat money2 = new DecimalFormat("0.00%"); //displays interest rate in decimal format DecimalFormat money = new DecimalFormat("#,###.00"); InputStreamReader reader = new InputStreamReader(System.in); BufferedReader object = new BufferedReader(reader); double loan = 200000.00; //Array int[] length = new int[3]; length[0]=7; length[1]=15; length[2]=30; double [] interest = new double [3]; interest[0] = .0535; interest[1] = .0550; interest[2] = .0575; int x = 0; do //Do Statement { double payment = (loan*(interest[x]/12))/(1-(Math.pow(1/(1+(interest[x]/12)),(length[x]*12)))); //Display Math System.out.println("\n\nYour Mortgage Payment " + twoplaces.format(payment) + "\n\nfor the " + length[x] + " Year Contract "); //Display Text to explane values x++; // displays messages to indicate purpose of program and conditions in the console window System.out.println(); System.out.println("Mortgage Payment Calculator"); System.out.println(); System.out.println("Calculate three separate mortgage payments for a $" + loanAmt); System.out.println("Length of Contract and Interest Rate: (1) 7 years @ 5.35%"); System.out.println("\t\t\t\t\t (2) 15 years @ 5.50%"); System.out.println("\t\t\t\t\t (3) 30 years @ 5.75%"); System.out.println(); System.out.println("The results:"); int i; for (i = 0; i <= 2; i++) { loanTerm[i] = loanTerm[i] / 12; intRate[i] = (intRate[i] * .01); monthlyPay = loanAmt * intRate[i] / (1 - Math.pow(1 + intRate[i], - loanTerm[i])); // displays results System.out.println(); System.out.println("Mortgage Payment For $" + loanAmt + " Length of Contract " + loanTerm[i] + " years at"); System.out.println("a " + (money2.format(intRate[i]) + " Interest Rate = " + (money.format(monthlyPay)))); } while (x <3); } } }
×
×
  • Create New...