Question

Question 1 (Marks: 35) Create a class named Customer that will determine the monthly repayment amount due by a customer for aSample Screen Shots: Customer Name Customer Contact Please enter the customer name Joe Bloggs OK Cancel Please enter the custProduct Price Please enter the price of the product 5000 OK Cancel Number of Months ? Please enter the number of repayment moThe following output is where interest is applicable: Message Customer Name: Joe Bloggs Customer Contact: 0821121547 Product

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

----------------

import javax.swing.JOptionPane;

public class Customer_Finance {

public static void main(String[] args) {

// TODO Auto-generated method stub

//two objects . first with interest and second with no interest

Finance_Period a=new Finance_Period();

a.setCustomerName();

a.setContactNumber();

a.setProductPrice();

a.setNumberOfMonths();

a.calculate_repayment();

display_info(a);

Finance_Period b=new Finance_Period();

b.setCustomerName();

b.setContactNumber();

b.setProductPrice();

b.setNumberOfMonths();

b.calculate_repayment();

display_info(b);

}

//displaying message box

public static void display_info(Customer c)

{

String info=String.format("Customer name:%s \n contact Number: %d \n product price: %f \n repayment months: %f\n monthly repayment %f\n total due: %f\n",c.customerName,c.contactNumber,c.productPrice,c.numberOfMonths,c.monthlyRepaymentAmount,c.monthlyRepaymentAmount*c.numberOfMonths);

JOptionPane.showMessageDialog(null, info);

}

}

------------

import javax.swing.JOptionPane;

public class Customer {

//variables for storing customer data

String customerName;

int contactNumber;

double productPrice;

double numberOfMonths;

double monthlyRepaymentAmount;

//getter and setter

public String getCustomerName() {

return customerName;

}

public void setCustomerName() {

this.customerName = JOptionPane.showInputDialog("please enter customer name: ");

}

public int getContactNumber() {

return contactNumber;

}

public void setContactNumber() {

this.contactNumber = Integer.parseInt(JOptionPane.showInputDialog("please enter contact number: "));

}

public double getProductPrice() {

return productPrice;

}

public void setProductPrice() {

this.productPrice = Double.parseDouble(JOptionPane.showInputDialog("please enter product price: "));

}

public double getNumberOfMonths() {

return numberOfMonths;

}

public void setNumberOfMonths() {

this.numberOfMonths = Double.parseDouble(JOptionPane.showInputDialog("please enter number of months: "));

}

public void calculate_repayment()

{

System.out.print("hello");

monthlyRepaymentAmount=productPrice/numberOfMonths;

}

}

-------------------

public class Finance_Period extends Customer {

//if months<=3 no interest or else interest

@Override

public void calculate_repayment() {

// TODO Auto-generated method stub

if(numberOfMonths<=3)

{

monthlyRepaymentAmount=productPrice/numberOfMonths;

}

else

{

double interest= (25.0/100.0) * productPrice;

double amount=productPrice + interest;

monthlyRepaymentAmount=amount/numberOfMonths;

}

}

}Quick Access = Fleet.java D Customer_Fin... X Customerjava Die Finance_Peri.. Dor - ETask List X 2 import javax.swing.JOption

Add a comment
Know the answer?
Add Answer to:
Question 1 (Marks: 35) Create a class named Customer that will determine the monthly repayment amount...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Summative Question 22

    Create a class named Customer that will determine the monthly repayment amount due by a customer for a product bought on credit. The class has five fields: customer name, contact number, product price, number of months and the monthly repayment amount. Write get and set methods for each field, except for the monthly repayment amount field. The set methods must prompt the user to enter the values for the following fields: customer name, contact number, product price and number of...

  • This problem will create a monthly ledger for a user to keep track of monthly bills....

    This problem will create a monthly ledger for a user to keep track of monthly bills.  The program will start by asking the user for an amount of monthly bills to pay.  Design of this solution will involve four classes, some may involve the use of previously written code: Class Design:  OurDate class – update your previously written OurDate class to include a toString() method. Be certain that you still have methods that will setDayFromUser(), setMonthFromUser() and...

  • a. Create a class named Lease with fields that hold an apartment tenant's name, apartment Number,...

    a. Create a class named Lease with fields that hold an apartment tenant's name, apartment Number, monthly rent amount, and term of the lease in months. Include a constructor that initializes the name. "XXX", the apartment number to O, the rent to 1000, and the term to 12. Also include methods to get and set each of the fields. Include a nonstatic method named addPetFee() that adds $10 to the monthly rent value and calls a static method named explainPetPolicy...

  • I'm a C++ beginner, I'm not sure how to do this. Calculate the amount a customer...

    I'm a C++ beginner, I'm not sure how to do this. Calculate the amount a customer should be charged at a gas station. Fees for the car wash are $4.25 with gasoline purchase of $35.00 or more and $10.00 otherwise. Three kinds of gasoline are available: regular at 3.39, unleaded at 3.55 and premium at 3.65 per gallon. Input consists of the customer number, number of gallons purchased, kind of gasoline purchased (R, U, P, or, for no purchase, N),...

  • PLEASE ANSWER IN C# 5. a. Create a Patient class for the Wrightstown Hospital Billing Department....

    PLEASE ANSWER IN C# 5. a. Create a Patient class for the Wrightstown Hospital Billing Department. Include auto-implemented prop- erties for a patient ID number, name, age, and amount due to the hospital, and include any other methods you need. Override the ToString method to return all the details for a patient. Write an application that prompts the user for data for five Patients. Sort them in patient ID number order and display them all, including a total amount owed....

  • MATLAB!!! CAN SOMEONE SOLVE THIS PROBLEM ON MATLAB?? THANK YOU PART B: HOUSING LOAN CALCULATOR In this part of the assignment, you are expected to develop a program that calculates housing loan pay-...

    MATLAB!!! CAN SOMEONE SOLVE THIS PROBLEM ON MATLAB?? THANK YOU PART B: HOUSING LOAN CALCULATOR In this part of the assignment, you are expected to develop a program that calculates housing loan pay- ments based on compound interest formulas The program should prompt a user to input the amount borrowed (principal), p, the number of monthly payments, n, and an annual interest rate in R percent. The program should convert the annual interest rate R into a monthly interest rate...

  • The Account class Create a class named Account, which has the following private properties: number: long...

    The Account class Create a class named Account, which has the following private properties: number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNumber(), getBalance(), setBalance(double newBalance). There is no setNumber() -- once an account is created, its account number cannot change. Now implement these methods: void deposit(double amount) and void withdraw(double amount). For both these methods,...

  • can you solve it in java please Create the following: 1. Class Invoice ( the node...

    can you solve it in java please Create the following: 1. Class Invoice ( the node ) that includes three instance variables:     int No; // the Invoice No             String CustName; // the Customer name             int Amount; // the Invoice Amount Invoice next; // points to the next Invoice Default and overloaded constructors 2. Class Shop that includes three instance variables: Invoice head; Invoice Tail; Your class should have the following: • A method that initializes the instance variables....

  • Question 1 (Marks: 50 Develop a Java GUI application that will produce an investment report based...

    Question 1 (Marks: 50 Develop a Java GUI application that will produce an investment report based on various criteria, such as investment amount, investment type and term. On the form create two text fields, one to capture the customer name and (10) Q.1.1 another to capture the amount to invest. Also create a combo box for the user to select the investment type which will be moderate or aggressive. Finally add three radio buttons for the user to select the...

  • analyze the students’ understanding in analyzing the given scenario and practical skills to build Class diagrams...

    analyze the students’ understanding in analyzing the given scenario and practical skills to build Class diagrams studied in chapters 8, 10 and 12 of IT242. The management of the groceries ordering system would desire to have a database system to keep track of orders, customers, drivers and stores. Read the following paragraph to answer the given questions. The system maintains four users' information. For each user, the system keeps a unique ID, name, login, password, address, contact number, category (Grocery...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT