Question: Using serialize code: The code i received and which i need to use and edit is: Account.java // Serializable Account class for storing records as

 Using serialize code: The code i received and which i need
to use and edit is: Account.java // Serializable Account class for storing
Using serialize code:
The code i received and which i need to use and edit is:
Account.java
// Serializable Account class for storing records as objects.
import java.io.Serializable;
public class Account implements Serializable
{
public static final long serialVersionUID = 1L;
private int account;
private String firstName;
private String lastName;
private double balance;
// initializes an Account with default values
public Account()
{
this(0, "", "", 0.0); // call other constructor
}
// initializes an Account with provided values
public Account(int account, String firstName,
String lastName, double balance)
{
this.account = account;
this.firstName = firstName;
this.lastName = lastName;
this.balance = balance;
}
// set account number
public void setAccount(int acct)
{
this.account = account;
}
// get account number
public int getAccount()
{
return account;
}
// set first name
public void setFirstName(String firstName)
{
this.firstName = firstName;
}
// get first name
public String getFirstName()
{
return firstName;
}
// set last name
public void setLastName(String lastName)
{
this.lastName = lastName;
}
// get last name
public String getLastName()
{
return lastName;
}
// set balance
public void setBalance(double balance)
{
this.balance = balance;
}
// get balance
public double getBalance()
{
return balance;
}
} // end class AccountRecordSerializable
Createdata.java
// Create data to put into an account file and a transactions file.
import java.io.IOException;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
public class CreateData
{
private static ObjectOutputStream outOldMaster, outTransaction;
public static void main(String[] args)
{
try
{
try
{
// file streams for output files
outOldMaster = new ObjectOutputStream(
new FileOutputStream("oldmast.ser"));
outTransaction = new ObjectOutputStream(
new FileOutputStream("trans.ser"));
}
catch (IOException io)
{
System.err.println("Error opening the file.");
}
try
{
outOldMaster.writeObject(new AccountRecordSerializable(
100, "Alan", "Jones", 348.17));
outOldMaster.writeObject(new AccountRecordSerializable(
300, "Mary", "Smith", 27.19));
outOldMaster.writeObject(new AccountRecordSerializable(
500, "Sam", "Sharp", 0.00));
outOldMaster.writeObject(new AccountRecordSerializable(
700, "Suzy", "Green", -14.22));
outTransaction.writeObject(
new TransactionRecord(100, 27.14));
outTransaction.writeObject(
new TransactionRecord(300, 62.11));
outTransaction.writeObject(
new TransactionRecord(300, -10.00));
outTransaction.writeObject(
new TransactionRecord(400, 100.56));
outTransaction.writeObject(
new TransactionRecord(900, 82.17));
}
catch (IOException io)
{
System.out.println("Error writing to the files.");
System.exit(1);
}
}
finally // close the files
{
try
{
if (outTransaction != null)
outTransaction.close();
if (outOldMaster != null)
outOldMaster.close();
}
catch (IOException io)
{
System.err.println("Error closing the files.");
System.exit(1);
}
}
}
} // end class CreateData

Assignment 2- File Matching Write a simple file matching account receivable program using object serialization. Modify the Account class as needed. Use package name filematch package yourinitials There should be a master file (eg: oldmaster.ser containing details about each account. As transactions occur, data is entered into a transaction file (Eg: trans ser) Your program should mimic a file matching process that occurs at the end of a business term period, where these transactions from the transaction file are applied to the old master file and it gets rewritten as a new master file (eg newmaster.ser") Attached are sample data for the master file and the transaction file. Master File Name Balance Account Number 100 Alan Jones 300 Mary Smith 27.19 500 Sam Sharp 0.00 1700 Suzy Green 4.22 Transaction File Account Number Transaction Amount(-ve values indicate payments) 27.14 100 300 62.11 300 0,00 100.56 400 Use the account number on each file as the record key for matching purposes. Assume that each file is a sequential file where records are stored in increasing account number order

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!