The Loan class in Listing 10.2 does not implement Serializable. Rewrite the Loan class to implement Serializable.
Question:
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.
Listing
Transcribed Image Text:
1 public class Loan { private double annualInterestRate; 2 private int numberofYears; 3 private double loanAmount; private java.util.Date loanDate; 4 6 /** Default constructor */ public Loan() { this(2.5, 1, 1000); 10 11 /** Construct a loan with specified annual interest rate, 12 13 number of years, and loan amount */ public Loan(double annualInterestRate, int numberOfYears, double loanAmount) { this. annualInterestRate = annualInterestRate; this.number0fYears = number0fYears; this. loanAmount = loanAmount; loanDate - new java.util.Date(); 14 15 16 17 18 19 20 21 22 23 /** Return annualInterestRate */ public double getAnnualInterestRate() { return annualInterestRate; 24 25 26 27 28 29 30 /** Set a new annualInterestRate */ public void setAnnualInterestRate(double annualInterestRate) { this. annualInterestRate = annualInterestRate; 31 32 33 /** Return numberofYears */ public int getNumberofYears () { return number0fYears; 34 35 36 37 38 /** Set a new numberOfYears */ public void setNumberofYears(int numberofYears) { this.numberofYears = number0fYears; 39 40 41 42 43 /** Return loanAmount */ public double getLoanAmount () { return loanAmount; 44 45 46 47 48 /** Set a new 1loanAmount */ public void setLoanAmount (double loanAmount) { this. loanAmount = loanAmount; 49 50 51 52 /** Find monthly payment */ public double getMonthlyPayment() { double monthlyInterestRate = annualInterestRate / 1200; double monthlyPayment = loanAmount * monthlyInterestRate / (1 - (1 / Math.pow(1i + monthlyInterestRate, number0fYears * 12))); return monthlyPayment; 53 54 55 56 57 58 59 60 61 /** Find total payment */ public double getTotal Payment () { double totalPayment = getMonthlyPayment () * numberofYears * 12; return totalPayment; 62 63 64 65 66 67 /** Return loan date */ public java.util.Date getloanDate() { return loanDate; 68 69 70 71 }
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 100% (7 reviews)
Output On execution the Exercise 196dat file gets generat...View the full answer
Answered By
Dorcas Juliet
I am a proficient tutor and writer with over 4 years experience, I can deliver A+ works in all fields related to business and economics subject. Kindly hire me for excellent papers
4.70+
10+ Reviews
51+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
Modify the Loan class in Listing 10.2 to throw IllegalArgumentException if the loan amount, interest rate, or number of years is less than or equal to zero. Listing 1 public class Loan { 2 private...
-
Rewrite the Course class in Listing 10.6 to add a clone method to perform a deep copy on the students field. Listing 1 public class Course { private String courseName; private String[] students = new...
-
Rewrite the Course class in Listing 10.6. Use an ArrayList to replace an array to store students. Draw the new UML diagram for the class. You should not change the original contract of the Course...
-
Tom Lamont, age 30, and Lin Lamont, age 31, have been married for six years. They got married right after Tom graduated from college. They have come to you for help in planning their financial...
-
Assume that all prices and income are positive (p > 0,m > 0) and that the consumer can afford some feasible consumption bundle, that is, Then the consumer's budget set X (p,m) is nonempty and...
-
A radar signal s(t), with amplitude V m = 100 V, consists of repeated tone bursts. Each tone burst lasts T b = 50 s. The bursts are repeated every T s = 10 ms. Find S eff and the average power in...
-
If you were trying to examine this issue, how would you proceed? Any suggestions for me to take next steps? same. Is that what happened? You normally wouldnt borrow money from the company, would you?
-
Use information on the endpapers of this book to calculate the average density of the Earth. Where does the value fit among those listed in Tables 1.5 and 14.1? Look up the density of a typical...
-
Pawan is pursuing MBA and shares a room with you in the private hostel. He desperately needs a job after completing his course because of educational loan and weak economic background. In his last...
-
How can an employee ethically justify inventing a job offer in order to pressure the boss into granting a raise?
-
Suppose a file named Exercise17_07.dat has been created using the ObjectOutputStream. The file contains Loan objects. The Loan class in Listing 10.2 does not implement Serializable. Rewrite the Loan...
-
Write a program that stores an array of the five int values 1, 2, 3, 4, and 5, a Date object for the current time, and the double value 5.5 into the file named Exercise17_05.dat.
-
Suppose a control chart is constructed so that the probability of a point falling outside the control limits when the process is actually in control is .002. What is the probability that ten...
-
References: https://files.eric.ed.gov/fulltext/ED501636.pdf Understanding your strengths and weaknesses is vital to developing as a leader. Have three people who know you complete the Leadership...
-
lizzie gunderson received a statement dated september 1st showing a balance of 16820 the card carries a finance charge rate of 16 if lizzie does not add any more charges to her card what is the...
-
Robin, age 23, is an employee participant of a 401(k) profit sharing plan sponsored by DL, LLC that is not top heavy. She has been an employee since her 19th birthday. DLs's plan uses the standard 21...
-
In what ways could individuals, communities, or societies experience adverse consequences as a result of misinformation or insufficient information disseminated through media channels?
-
How might we design this study of depression and relationships? Which statistical tests do we use for which designs? What are our independent and dependent variables? What kind of variables are they...
-
Refer to the data for Ruby Gordon, L.L.B. in EB-8. Assume instead that Ruby is operating her legal practice in Alberta and that on June 30 she paid a quarterly remittance of GST, as opposed to HST,...
-
Before the latest financial crisis and recession, when was the largest recession of the past 50 years, and what was the cumulative loss in output over the course of the slowdown?
-
Consider a variant of Exercise C-7.29, in which an array of capacity N, is resized to capacity precisely that of the number of elements, any time the number of elements in the array goes strictly...
-
In Section 7.5.3, we demonstrated how the Collections.shuffle method can be adapted to shuffle a reference-type array. Give a direct implementation of a shuffle method for an array of int values. You...
-
Give an implementation of the deque ADT using an array list for storage.
-
-> Let G and H be groups. A function : G H is called a (group) homomorphism if it satisfies (9192) = (91) * (92) for all 91, 92 G. (Note that the product 91*92 uses the group law in the group G,...
-
Complete the table for the point (2, 2). f(x) (2, 2) f(2x) 6f(2x) 6f(2(x+1))- -3
-
I hired a carpenter and an apprentice to do some work at my business. They worked two days. On the first day I was billed $210 for 11 hours of work by the main carpenter and for 7 hours of work by...
Study smarter with the SolutionInn App