public class Loan { private double annualInterestRate; private int numberOfYears; private double loanAmount; private java.util.Date loanDate; /** Default constructor */ public Loan() { this(2.5, 1, 1000); } /** * Construct a loan with specified annual interest rate, number of years and * loan amount */ public Loan(double annualInterestRate, int numberOfYears, double loanAmount) { this.annualInterestRate = annualInterestRate; this.numberOfYears = numberOfYears; this.loanAmount = loanAmount; loanDate = new java.util.Date(); } /** Return annualInterestRate */ public double getAnnualInterestRate() { return annualInterestRate; } /** Set a new annualInterestRate */ public void setAnnualInterestRate(double annualInterestRate) { this.annualInterestRate = annualInterestRate; } /** Return numberOfYears */ public int getNumberOfYears() { return numberOfYears; } /** Set a new numberOfYears */ public void setNumberOfYears(int numberOfYears) { this.numberOfYears = numberOfYears; } /** Return loanAmount */ public double getLoanAmount() { return loanAmount; } /** Set a newloanAmount */ public void setLoanAmount(double loanAmount) { this.loanAmount = loanAmount; } /** Find monthly payment */ public double getMonthlyPayment() { double monthlyInterestRate = annualInterestRate / 1200; double monthlyPayment = loanAmount * monthlyInterestRate / (1 - (Math.pow(1 / (1 + monthlyInterestRate), numberOfYears * 12))); return monthlyPayment; } /** Find total payment */ public double getTotalPayment() { double totalPayment = getMonthlyPayment() * numberOfYears * 12; return totalPayment; } /** Return loan date */ public java.util.Date getLoanDate() { return loanDate; } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Done in javaFx  and the Listing 10.2 (Loan.java) is down below.

 

public class Loan {
private double annualInterestRate;
private int numberOfYears;
private double loanAmount;
private java.util.Date loanDate;

/** Default constructor */
public Loan() {
this(2.5, 1, 1000);
}

/**
* Construct a loan with specified annual interest rate, number of years and
* loan amount
*/
public Loan(double annualInterestRate, int numberOfYears, double loanAmount) {
this.annualInterestRate = annualInterestRate;
this.numberOfYears = numberOfYears;
this.loanAmount = loanAmount;
loanDate = new java.util.Date();
}

/** Return annualInterestRate */
public double getAnnualInterestRate() {
return annualInterestRate;
}

/** Set a new annualInterestRate */
public void setAnnualInterestRate(double annualInterestRate) {
this.annualInterestRate = annualInterestRate;
}

/** Return numberOfYears */
public int getNumberOfYears() {
return numberOfYears;
}

/** Set a new numberOfYears */
public void setNumberOfYears(int numberOfYears) {
this.numberOfYears = numberOfYears;
}

/** Return loanAmount */
public double getLoanAmount() {
return loanAmount;
}

/** Set a newloanAmount */
public void setLoanAmount(double loanAmount) {
this.loanAmount = loanAmount;
}

/** Find monthly payment */
public double getMonthlyPayment() {
double monthlyInterestRate = annualInterestRate / 1200;
double monthlyPayment = loanAmount * monthlyInterestRate
/ (1 - (Math.pow(1 / (1 + monthlyInterestRate), numberOfYears * 12)));
return monthlyPayment;
}

/** Find total payment */
public double getTotalPayment() {
double totalPayment = getMonthlyPayment() * numberOfYears * 12;
return totalPayment;
}

/** Return loan date */
public java.util.Date getLoanDate() {
return loanDate;
}
}

* 17.6 (Store Loan objects) The Loan class in Listing 10.2 does not implement
Serializable. Rewrite the Loan class to implement Serializable. Write
a program that creates five Loan objects and stores them in a file named
Exercise17_06.dat.
*17.7 (Restore objects from a file) Suppose a file named Exercise17_06.dat has
been created using the ObjectOutputStream from the preceding program-
ming exercises. The file contains Loan objects. The Loan class in Listing 10.2
does not implement Serializable. Rewrite the Loan class to implement
Serializable. Write a program that reads the Loan objects from the file and
displays the total loan amount. Suppose that you don't know how many Loan
objects are there in the file, use EOFException to end the loop.
Upload three files for this exercise:
Exercise17_07.java
Exercise17_06.java
Load.java (your modified version)
Transcribed Image Text:* 17.6 (Store Loan objects) The Loan class in Listing 10.2 does not implement Serializable. Rewrite the Loan class to implement Serializable. Write a program that creates five Loan objects and stores them in a file named Exercise17_06.dat. *17.7 (Restore objects from a file) Suppose a file named Exercise17_06.dat has been created using the ObjectOutputStream from the preceding program- ming exercises. The file contains Loan objects. The Loan class in Listing 10.2 does not implement Serializable. Rewrite the Loan class to implement Serializable. Write a program that reads the Loan objects from the file and displays the total loan amount. Suppose that you don't know how many Loan objects are there in the file, use EOFException to end the loop. Upload three files for this exercise: Exercise17_07.java Exercise17_06.java Load.java (your modified version)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
void method
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education