Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Summary Create a Loan class(in JAVA), instantiate and write several Loan objects to a file, read them back in, and format a report. Project Description

Summary

Create a Loan class(in JAVA), instantiate and write several Loan objects to a file, read them back in, and format a report.

Project Description

This this lab, youll read and write files containing objects of the Loan class. Here are the details of that class:

Instance Variables: customer name (String) annual interest percentage (double) number of years (int) loan amount (double) loan date (String) monthly payment (double) total payments (double)

Methods:

  • getters for all instance variables
  • setters for all instance variables except monthly payment and total payment
  • calculateMonthlyPayment and calculateTotalPayments

The setters for the annual interest percentage, number of years, and loan amount invoke both calculate methods before they exit

The calculate methods compute the named value, then store that amount in the associated instance variable. They are private (helper) methods.

Constructors:

  • a no-arg constructor sets the customer name to a default value, the loan date to no date, and all numeric variables to zero. This method invokes the full constructor
  • a full constructor takes the customer name, annual interest percentage, number of years, loan amount, and loan date. It invokes the appropriate setters, but doesnt need to invoke the calculate methods (why?)

Calculations:

monthly interest rate = annual interest percentage / 1200

monthly payment = (loan amount * monthly interest rate) / (1 Math.pow( (1 + monthly interest rate), (number of years * 12) ) )

total loan payments = monthly payment * number of years * 12

* Note: Round all dollar amounts to 2 decimal places

Here is what you should do in main

Use this data to create five Loan objects

 Annual Interest Loan  Customer Name Percentage Years Amount Loan Date Bob Smith 6.5% 30 318,000 Sep 1, 2015 Alicia Herman 4.2% 15 248,000 Oct 15, 2013 Julie Franciosa 8.5% 10 30,000 Apr 14, 2010 Julio Quiros 15.0% 3 50,000 June 23, 2017 Frank Larsen 8.9% 5 23,000 Mar 8, 2016

Use this summary algorithm for your program:

  1. Make the Loan class Serializable
  2. Instantiate Loan objects representing the first three loans above using the full constructor
  3. Create an output stream and store the three objects into a binary file using the writeObject method
  4. Instantiate Loan objects representing the last two loans above using the no-arg constructor, then use setters to update information about those loans
  5. Append those objects to the output stream created above in step 2
  6. Close the output stream
  7. Create an input stream and read the objects from the binary file above and display in a nicely formatted columnar report
  • Write your code to handle any number of loan objects (i.e., do not assume that there are 5 Loan objects in the file
  • Include in your report the monthly loan payment and total loan payment amounts
  • Display totals for the amount of the loan amounts, monthly payments, and total loan payments.
  1. Close the input stream

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions

Question

Hist (enter your responsto as a nibolo number)

Answered: 1 week ago

Question

Which form of proof do you find least persuasive? Why?

Answered: 1 week ago