I need some help with the following instructions because I find it so hard that I'm so desperately want to solve it: These are the instructions: The program will also include entry of the name(s) for the mortgagee (person taking out the loan for the mortgage) and the date the calculations were made. The program will also ask if the client wants to run the program again [that way the Smiths' will be able to see what their monthly mortage payment will be if they take out a 30-year, 20-year, or 10-year mortgage. (I have implemented this part already but please check it again maybe my code is incorrect) The formula to calculate the monthly payment is as follows: Fixed Monthly Mortgage Repayment Calculation = P * r * (1 + r)n / [(1 + r)n - 1] where P = Outstanding loan amount, r = Effective monthly interest rate (divide r by 12), n = Total number of periods (i.e., years x 12 months) This is my Code it's working already but I need to add some features and corrections. import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String a=" "; do{ System.out.println(java.time.LocalDateTime.now()); System.out.println("Enter name"); String name=sc.nextLine(); System.out.println("Enter the purchase price"); int pp=sc.nextInt(); System.out.println("Enter the downpayment"); int dp=sc.nextInt(); /* if down payment is in percentage then convert it to amount int amount=(dp/100)*pp System.out.println(amount); */ System.out.println("Loan amount"); float la=pp-dp; System.out.println(la); System.out.println("Interest rate"); float ir=sc.nextFloat(); System.out.println("No of years of mortage"); float time=sc.nextInt(); float r=ir/12; float n=time*12; float x = dp * r * (1 + r)*n; float y = (1 + r)*n - 1; float montlyrate=x/y; System.out.println(montlyrate); System.out.println("do you want to continue?then type Yes"); a=sc.next(); } while(a=="Yes"); } }
I need some help with the following instructions because I find it so hard that I'm so desperately want to solve it:
These are the instructions:
The program will also include entry of the name(s) for the mortgagee (person taking out the loan for the mortgage) and the date the calculations were made. The program will also ask if the client wants to run the program again [that way the Smiths' will be able to see what their monthly mortage payment will be if they take out a 30-year, 20-year, or 10-year mortgage.
(I have implemented this part already but please check it again maybe my code is incorrect)
The formula to calculate the monthly payment is as follows:
Fixed Monthly Mortgage Repayment Calculation = P * r * (1 + r)n / [(1 + r)n - 1]
where P = Outstanding loan amount, r = Effective monthly interest rate (divide r by 12), n = Total number of periods (i.e., years x 12 months)
This is my Code it's working already but I need to add some features and corrections.
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String a=" ";
do{
System.out.println(java.time.LocalDateTime.now());
System.out.println("Enter name");
String name=sc.nextLine();
System.out.println("Enter the purchase price");
int pp=sc.nextInt();
System.out.println("Enter the downpayment");
int dp=sc.nextInt();
/* if down payment is in percentage then convert it to amount
int amount=(dp/100)*pp
System.out.println(amount);
*/
System.out.println("Loan amount");
float la=pp-dp;
System.out.println(la);
System.out.println("Interest rate");
float ir=sc.nextFloat();
System.out.println("No of years of mortage");
float time=sc.nextInt();
float r=ir/12;
float n=time*12;
float x = dp * r * (1 + r)*n;
float y = (1 + r)*n - 1;
float montlyrate=x/y;
System.out.println(montlyrate);
System.out.println("do you want to continue?then type Yes");
a=sc.next();
}
while(a=="Yes");
}
}
Step by step
Solved in 2 steps with 1 images