LoanSerializablejava WriteLoanObjectsjava ReadLoadObjectsjav

LoanSerializable.java, WriteLoanObjects.java, ReadLoadObjects.java, Date.java Write the LoanSerializable.java class to implement Serializable. Write a program WriteLoanObjects.java that creates five Loan objects and stores them in a file named LoanObjects.dat. (Restore objects from a file). Write a program ReadLoanObjects.java that reads the Loan objects from the file and displays the total loan amount. Suppose you don\'t know how many Loan objects are there in the file, use EOFException to end the loop. Methods and attributes of Loan class General instructions Use try...catch blocks

Solution

Code to copy:

// class file name: writeobjects.class

// file name: wirteobjects.java

import java.io.*;

/**

* This class file writes a number of Loan objects to a file Objects.dat, to be read

* from another class Lab09ReadObjects.

*/

public class Lab09WriteObjects {

public static void main(String[] args) throws IOException {

    ObjectOutputStream output = new ObjectOutputStream(

      new FileOutputStream(\"Objects.dat\"));

    output.writeObject(new Loan(2.5, 5, 100000));

    output.writeObject(new Loan(3.5, 5, 200000));

    output.writeObject(new Loan(4.5, 5, 300000));

    output.writeObject(new Loan(5.5, 5, 400000));

    output.writeObject(new Loan(6.5, 5, 500000));

    output.close();

    System.out.println(\"5 Loan Objects written to file Objects.dat\");

}

}

// file name: Loan.class

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

// file name: loan.ctxt

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

// file name:loan.java

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

//file name: Testloan.class

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

// file name: TestLoan.ctxt

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

//file name: TestLoan.java

 LoanSerializable.java, WriteLoanObjects.java, ReadLoadObjects.java, Date.java Write the LoanSerializable.java class to implement Serializable. Write a program
 LoanSerializable.java, WriteLoanObjects.java, ReadLoadObjects.java, Date.java Write the LoanSerializable.java class to implement Serializable. Write a program

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site