Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please assist i ' m trying to run the following source code on Apache NetBeans IDE 2 1 software so i can take screenshots for
Please assist im trying to run the following source code on Apache NetBeans IDE software so i can take screenshots for my assisgnement i t gives me an error please assist in correcting the error. NB I want all calculations to be in South African Rands. import java.util.Scanner; public class MortgageCalculator public static void mainString args Create a Scanner object for user input Scanner scanner new ScannerSystemin; Prompt user to enter loan amount System.out.printEnter the loan amount in rands: ; double loanAmount scanner.nextDouble; Prompt user to enter annual interest rate System.out.printEnter the annual interest rate as a percentage: ; double annualInterestRate scanner.nextDouble; Prompt user to enter loan term in years System.out.printEnter the loan term in years: ; int loanTermYears scanner.nextInt; Calculate monthly interest rate Convert annual interest rate from percentage to decimal and divide by for monthly rate double monthlyInterestRate annualInterestRate ; Calculate number of monthly payments Multiply loan term in years by to get total number of payments int numberOfPayments loanTermYears ; Calculate monthly mortgage payment using formula: M Prrnrn where M is the monthly payment, P is the principal loan amount, r is the monthly interest rate, and n is the number of payments double monthlyPayment loanAmount monthlyInterestRate Math.pow monthlyInterestRate, numberOfPayments; Display the calculated monthly payment Use printf to format the output to two decimal places System.out.printfMonthly Mortgage Payment: R fn monthlyPayment; Close the scanner to prevent resource leak scanner.close;
Please assist im trying to run the following source code on Apache NetBeans IDE software so i can take screenshots for my assisgnement i t gives me an error please assist in correcting the error.
NB I want all calculations to be in South African Rands.
import java.util.Scanner;
public class MortgageCalculator
public static void mainString args
Create a Scanner object for user input
Scanner scanner new ScannerSystemin;
Prompt user to enter loan amount
System.out.printEnter the loan amount in rands: ;
double loanAmount scanner.nextDouble;
Prompt user to enter annual interest rate
System.out.printEnter the annual interest rate as a percentage: ;
double annualInterestRate scanner.nextDouble;
Prompt user to enter loan term in years
System.out.printEnter the loan term in years: ;
int loanTermYears scanner.nextInt;
Calculate monthly interest rate
Convert annual interest rate from percentage to decimal and divide by for monthly rate
double monthlyInterestRate annualInterestRate ;
Calculate number of monthly payments
Multiply loan term in years by to get total number of payments
int numberOfPayments loanTermYears ;
Calculate monthly mortgage payment using formula:
M Prrnrn
where M is the monthly payment, P is the principal loan amount,
r is the monthly interest rate, and n is the number of payments
double monthlyPayment loanAmount monthlyInterestRate
Math.pow monthlyInterestRate, numberOfPayments;
Display the calculated monthly payment
Use printf to format the output to two decimal places
System.out.printfMonthly Mortgage Payment: R fn monthlyPayment;
Close the scanner to prevent resource leak
scanner.close;
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