Java programming Java programming Assume you bought a laptop based on monthly pa
ID: 3876521 • Letter: J
Question
Java programming Java programming Assume you bought a laptop based on monthly payments and a down payment. W program to calculate (a) interest paid at the end of the payment period, (b) annual rate (APR) that this interest amount will result in, and (c) the total finance charges. program should read from the keyboard the price of the laptop (p), the down payment( monthly payment (m), and the number of months (n) of the loan period. (Example p-si 285, d=$60. m=$55, n=24, (a) Amount of loan over 24 months price-don payment = 1285-60 = $1225. Interest paid amount paid-the loan amount (24*55) 1225 = 1320-1225-$95. (b) interest/price -95/1285-0.074, APR=7.4%. (c) Finance charge-price + interest = 1 285+95-si 380)Explanation / Answer
import java.util.Scanner;
class Main {
public static void main(String[] args) {
// variables that are available
int p, d, m, n;
// to be calculated
int loan, interest, finance;
double apr;
// declaring scanner for input
Scanner sc = new Scanner(System.in);
// taking user input
System.out.print("Enter the price of the laptop: $");
p = sc.nextInt();
System.out.print("Enter down payement: $");
d = sc.nextInt();
System.out.print("Enter monthly payment: $");
m = sc.nextInt();
System.out.print("Enter number of months of the loan period: ");
n = sc.nextInt();
// calculating
loan = p - d;
interest = (n*m) - loan;
apr = (interest*100.0 / p*1.0);
finance = p + interest;
// printing
System.out.println(" Amount of loan over "+ m + " months = "+ loan);
System.out.println("Interest = "+interest);
System.out.printf("APR = %.1f ",apr);
System.out.println("Finacne Charge = "+finance);
}
}
/*SAMPLE OUTPUT
Enter the price of the laptop: $ 1285
Enter down payement: $ 60
Enter monthly payment: $ 55
Enter number of months of the loan period: 24
Amount of loan over 55 months = 1225
Interest = 95
APR = 7.4
Finacne Charge = 1380
*/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.