Question: why did this program run all the way through correctly ? 15 3 import java. 4 //main class 5 public class Project3 6 //main method

![method 7 8 public static void main(String [] args) { 9 double](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f30cfe762a2_60666f30cfe13c76.jpg)
15 3 import java. 4 //main class 5 public class Project3 6 //main method 7 8 public static void main(String [] args) { 9 double c, monthly amt, total_amt, total_intrestant; 10 Scanner sc-new Scanner(System.in); 11 System.out.println("Enter the mortgage prinicple: 100 "); 12 W/prompt user to enter mortgage principal 13 int pesc.nextInt(); System.out.println("enter the length of mortgage" ); 1/prompt user to enter the length of mortgage 16 int yearusc.nextInt(); 17 System.out.println("enter the annual intrest rate: "); 18 //prompt user to enter annual intrest rate 19 double rate=sc.nextDouble(); 2e V/convert length from years to months 21 int n=year*12; 22 1/convert annual intrest rate to monthly intrest rate 23 double r=rate/1200; 24 V/computing monthly interest payment 25 C= (p*r* (Math.pow((1+r), n))) /((Math.pow((1+r),n))-1); 26 /computing monthly payment 27 monthly_amt=c+P; 28 W/computing total payment 29 total_amt=monthly_amt*n; V/computing total interest payment 31 total_intrestamt=c*n; 32 W/printing monthly payment 33 System.out.printf("monthly payment:%.2f%n", monthly amt); 34 //printing total payment 35 System.out.println("Total payment: "+Math.round(totai_amt)); 36 i/printing total intrest payment 37 System.out.println("Total intrest pay:"+Math.round(total_intrestamt)); mm Writable Smart Insert 41 Problems Javadoc Declaration Console x Project3 [Java Application) C:\Users\SSU Student\.p2\pool\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64. 15. Enter the mortgage prinicple: 100 Writable Smart Insert 15:58 (50) C I Procedure The monthly payment c of a mortgage of n months with monthly interest rate r for a principal pis given by the mathematical formula. pr(1+r)" C= (1 + r)" - 1 Write a Java program to calculate the monthly payment. Be sure to use Scanner to gather user input. 1. Prompt the user to enter the mortgage principal in dollars as an integer, 2. Prompt the user to enter the length of the mortgage in years as an integer. 3. Prompt the user to enter the annual interest rate in percentage as a double value. 4. Convert the length from years to months. 5. Convert the annual percent interest rate to monthly absolute interest rate. 6. Compute the monthly payment in double type. 7. Compute the total payment of the mortgage. 8. Compute the total interest payment of the mortgage. 9. Print the monthly payment, rounded to cents. 10. Print the total payment, rounded to dollars. 11. Print the total interest payment, rounded to dollars
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
