Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python 3.6 i need the code ready to run with adequate indentation Sample run: Th

ID: 3847290 • Letter: P

Question

Python 3.6

i need the code ready to run with adequate indentation

Sample run:

The monthly payment for a given loan pays the principal and the interest. The monthly interest is computed by multiplying the monthly interest rate and the balance (the remaining principal). The principal paid for the month is therefore the monthly payment minus the monthly interest. Write a program that lets the user enter the loan amount, number of years, and interest rate, and then displays the amortization schedule for the loan.

Explanation / Answer

Import java.io.*;

Import java.lang.*;

import java.util.Scanner;
class Amortization

{

public static void main(String[] args)

{
      double p,iy;
   int n;
   Scanner sc=new Scanner(System.in);
      System.out.print("Enter loan amout:");
  

p=sc.nextFloat();
   System.out.print("Enter number of years in integers:");

   iy=sc.nextFloat();
   System.out.print("Enter yeary interest rate:");

iy=sc.nextFloat();
   System.out.print("Enter monthly payment:");

   n=sc.nextInt();    

iy=sc.nextFloat();
   System.out.print("Total Payment:");
        calAmort(p,iy,n);
  
   }

   public static void calAmort(double p,double iy, int ny){
    double newbal;
    double im=(iy/12)/100;
    int nm=ny*12;
     double mp,ip,pp;
   int i;
  
         mp=p*im*Math.pow(1+im,(double)nm)/(Math.pow(1+im,(double)nm)-1);
         printHeader();
         //print amortization schedule for all months except the last month
         for(i=1;i<nm;i++){   
           ip=p*im;//interest paid
           pp=mp-ip; //princial paid
           newbal=p-pp; //new balance   
        printSch(i,p,mp,ip,pp,newbal);
           p=newbal; //update old balance
   }
      //last month
   pp=p;
   ip=p*im;
      mp=pp+ip;
   newbal=0.0;
   printSch(i,p,mp,ip,pp,newbal);   
  
  }
  
public static void printSch(int i,double p,double mp,double ip,double pp,double newbal){
  
   System.out.format("%-8d%-12.3f%-10.3f%-10.3f%-10.3f%-12.3f ",i,p,mp,ip,pp,newbal);
  
   }

public static void printHeader(){
   int i;
      System.out.println(" Amortization amount total");
      for(i=0;i<62;i++) System.out.print("-");
   System.out.format(" %-8s%-12s%-10s%-10s%-10s%-12s"," ","Old","Monthly","Interest","Principle","New","Balance");
   }   
}