I want a working java code which calcuates and shows like this in the output. I
ID: 3578465 • Letter: I
Question
I want a working java code which calcuates and shows like this in the output. I have a sample code from my instructor which can be used as a sample but the output should be the same which can calculate everything.
<HTML> <FORM NAME="loandata"> <TABLE> <TR><TD COLSPAN=3><BIG><B>Enter Loan Information:</B></BIG></TD></TR> <TR> <TD>1)</TD> <TD>Amount of the Loan (Any Currency):</TD> <TD><INPUT TYPE=text NAME=principal SIZE=12 ></TD> </TR> <TR> <TD>2)</TD> <TD>Annual Percentage Rate of Interest:</TD> <TD><INPUT TYPE=text NAME=interest SIZE=12 ></TD> </TR> <TR> <TD>3)</TD> <TD>Repayment Period in Years:</TD> <TD><INPUT TYPE=text NAME=years SIZE=12 ></TD> </TR> <TR><TD COLSPAN=3> <BIG><B> <INPUT TYPE=button VALUE="Compute" > <BR>Payment Information: </B></BIG> </TD></TR> <TR> <TD>4)</TD> <TD>Your Monthly Payment will be:</TD> <TD><INPUT TYPE=text NAME=payment SIZE=12</TD> </TR> <TR> <TD>5)</TD> <TD>Your Total Payment will be:</TD> <TD><INPUT TYPE=text NAME=total SIZE=12</TD> </TR> <TR> <TD>6)</TD> <TD>Your Total Interest Payments will be:</TD> <TD><INPUT TYPE=text NAME=totalinterest SIZE=12</TD> </TR> </TABLE> </FORM> <SCRIPT LANGUAGE="JavaScript"> function calculate() { var principal = document.loandata.principal.value; var interest = document.loandata.interest.value /100 /12; var payments = document.loandata.years.value *12; var x = Math.pow(1 + interest, payments); var monthly = (principal * x * interest)/(x-1); if ((!isNaN(monthly)) && (monthly != Number.POSITIVE_INFINITY) && (monthly != Number.NEGATIVE_INFINITY) ) { document.loandata.payment.value=(monthly); document.loandata.total.value=(monthly * payments); document.loandata.totalinterest.value=((monthly * payments) - principal); } else { document.loandata.payment.value=""; document.loandata.total.value=""; document.loandata.totalinterest.value=""; } } </SCRIPT> </HTML> ACC111 35654 Grad x X D COM263 Lesson 9 x Final Project C Loan. M 2016 F x O view-source:https://lea x XC Chegg Study I Guided X https:// earn maricopa edu/ /940022/ files/41303 776 E CSC110 20506 Files Loan. htm EM 2016 FALL CRED Loan html Home Download Loan.html (1.83 KB) Announcements Enter Loan Information: Syllabus Dashboard 1) Amount of the Loan (Any Currency) Modules 2) Annual Percentage Rate of Interest 3) Repayment Period in Years Courses Grades Compute People Payment Information: Calendar Conferences 4) Your Monthly Payment will be: 5) Your Total Payment will be: Chat 6) Your Total Interest Payments will be: Help Library C Logout Loan (4).html Ask me anything Show all X a 8-01 PM 4x 2/10/2016Explanation / Answer
Here goes your java code
import java.util.Scanner;
public class LoanCalculator {
public LoanCalculator() {
Scanner sc = new Scanner(System.in);
System.out.printf("Amount of loan (Any Currency) : ");
double principalValue = sc.nextDouble();
System.out.printf("Annual Percentage Rage of Interest : ");
double interestRatePercent = sc.nextDouble();
System.out.printf("Repayment Periods in Years : ");
int repaymentYears = sc.nextInt();
calculate(principalValue, interestRatePercent, repaymentYears);
sc.close();
}
public void calculate(double principalValue, double interestRatePercent,
int repaymentYears) {
int paymentMonths = repaymentYears * 12;
double monthlyInterestRate = interestRatePercent /100 /12;
double tempFactor = Math.pow((1+monthlyInterestRate), paymentMonths);
double monthlyPayment = (principalValue * tempFactor * monthlyInterestRate) / (tempFactor - 1);
System.out.println("Your monthly payment will be : " + monthlyPayment);
System.out.println("Your total payment will be : " + monthlyPayment * paymentMonths);
System.out.println("Your total Interest Pyament will be : "+ ((monthlyPayment * paymentMonths) - principalValue));
}
public static void main(String args[]) {
new LoanCalculator();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.