Answer to Question #235831 in Java | JSP | JSF for Siya

Question #235831

Add a subclass named Finance_Period that will determine if a customer will pay interest or not. If the number of months to pay for the product is greater than three, the customer will pay 25% interest, else no interest applies. The maximum number of months to pay for the product is 12. Override the calculate_repayment () method by determining if the customer will pay interest or not and calculate the monthly repayment amount.


Create a class called Customer_Finance that contains the logic to test the two classes. Prompt the user for data for the first object where no interest applies and display the results; then prompt the user for data where interest is applicable and display the results.


1
Expert's answer
2021-09-10T18:48:54-0400
public class FinancePeriod extends SomeClass {
    @Override
    public double calculateRepayment() {
        double repayment = price / numberOfMonth;
        if (numberOfMonth >= 3) {
            repayment += (price * 0.25) / numberOfMonth;
        }
        return repayment;
    }
}


import java.util.Scanner;

public class CustomerFinance {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        SomeClass someClass = new SomeClass();
        FinancePeriod financePeriod = new FinancePeriod();

        someClass.setPrice(Double.parseDouble(in.nextLine()));
        someClass.setMonths(Integer.parseInt(in.nextLine()));
        System.out.println(someClass.calculateRepayment());

        financePeriod.setPrice(Double.parseDouble(in.nextLine()));
        financePeriod.setMonths(Integer.parseInt(in.nextLine()));
        System.out.println(financePeriod.calculateRepayment());
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS