Answer:
// program in java.
import java.util.*;
class Main
{// main method of class
public static void main (String[] args) throws java.lang.Exception
{
try{
// object to read input
Scanner scr=new Scanner(System.in);
System.out.print("Enter balance:");
// read balance
float bal=scr.nextFloat();
System.out.print("Enter interest(in %):");
// read interest
float inte=scr.nextFloat();
// calculate monthly mortgage
float month_mort=bal*inte/1200;
// print the mortgage
System.out.printf("monthly mortgage is: %.2f",month_mort);
}catch(Exception ex){
return;}
}
}
Step-by-step explanation:
Read the balance and annual interest from user with help of Scanner object. Then calculate the monthly mortgage by formula Interest = balance x (annualInterestRate / 1200). Print the monthly mortgage.
Output:
Enter balance:10000
Enter interest(in %):4.25
monthly mortgage is: 35.42