Question
need a java structure chart for my below java program import java.util.Scanner; public class Problem_5_22 { public static void main(String[] args) { boolean run =
need a java structure chart for my below java program
import java.util.Scanner;
public class Problem_5_22 { public static void main(String[] args) { boolean run = true; while(run) { //Creates a Scanner to take in user input Scanner input = new Scanner(System.in);
//Prompts the user to enter the loan amount, the number of years //and the annual interest rate System.out.printf(" Loan Amount: "); double loanAmount = input.nextDouble(); System.out.printf("Number of Years: "); int years = input.nextInt(); System.out.printf("Annual Interest Rate: "); double annualRate = input.nextDouble();
//Calculates the monthly interest rate double monthlyRate = annualRate/1200;
//Calculates the monthly payment amount double monthlyPayment = loanAmount * monthlyRate / (1-1/Math.pow(1 + monthlyRate, years * 12));
//Displays the monthly payment amount System.out.printf("Monthly Payment: %.2f ", monthlyPayment);
//Displays total payments made YTD System.out.printf("Total Payment: %.2f ", (monthlyPayment * 12) * years);
//Creates the amortization/payment schedule and displays by month double balance = loanAmount, principal, interest; System.out.println("Payment# Interest Principal Balance"); for (int i = 1; i <= years * 12; i++) { interest = monthlyRate * balance; principal = monthlyPayment - interest; balance = balance - principal; System.out.printf("%-13d%-13.2f%-13.2f%.2f ", i, interest, principal, balance); } } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started