Develop a java application that meets the following program description:

a. An appliance store is offering 3% financing for 12 months on any purchase.
b. Use constants for the finance rate and number of months.
c. Have the user enter the item purchased and the purchase price.
d. Format ALL numeric output with two decimals, tell the user how much the monthly payment will be (using the formula below) and the total amount to be paid.
e. Lastly, display the amount ‘extra’ paid. monthly payment = ( (purchase price* financing rate) + purchase price) / months.

Respuesta :

Answer:

import java.util.Scanner;

public class Appliance

{

public static void main(String[] args) {

   

    final double financingRate = 0.03;

    final int numberOfMonths = 12;

    Scanner input = new Scanner(System.in);

   

    System.out.print("Enter the item you want to purchase: ");

    String itemPurchased = input.nextLine();

    System.out.print("Enter the price for the item: ");

    double purchasePrice = input.nextDouble();

       

       double monthlyPayment = ((purchasePrice * financingRate) + purchasePrice) / numberOfMonths;

       double totalPayment = monthlyPayment * numberOfMonths;

double extra = totalPayment - purchasePrice;

   

System.out.print("You purchased "+ itemPurchased+ "\nYour monthly payment is: "+ (String.format("%.2f",monthlyPayment)) + "\nYour total payment is: "+ (String.format("%.2f",totalPayment)) + "\nYour extra payment is: "+ (String.format("%.2f",extra)));

}

}

Explanation:

- financingRate and numberOfMonths are initialized as constant.

- Scanner object is used to get purchased item and price.

- monthlyPayment is calculated using the given formula.

- totalPayment is calculated by multiplying monthlyPayment and 12.

- extra is calculated by subtracting purchasePrice from totalPayment.

- All the required things are printed out. Be aware that since numbers are required to have two decimal points, String.format("%.2f", variableName) is used.