Starting from:

$30

CSIT121-Java Lab 4 Solved

Question 1 

 

In this lab task you are required to write a Java application that reads and writes objects from/to a file.  

 

Step 1 
 

Declare and implement a class named InventoryItem based on the class diagram given below: 

 

 

InventoryItem 
 

-  serialNum : int 

-  description : String 

-  costPrice : double 

-  sellingPrice : double 

-  quantityInHand : int 

 
 

+ InventoryItem() 

+ setSerialNum(int) : void 

+ setDescription(String) : void 

+ setCostPrice (double) : void 

+ setSellingPrice (double) : void 

+ setQuantityInHand(int) : void 

+ getSerialNum() : int 

+ getDescription() : String 

+ getCostPrice () : double 

+ getSellingPrice () : double 

+ getQuantityInHand() : int 

+ getTotalRevenue() : double  
 

 

 

 

Step 2 
 

Write a Java application that performs the following operations: 

 

-      Prompt the user to enter information for several InventoryItem objects that are stored in an ArrayList.

-      Save all the InventoryItem objects in a simple csv text file (i.e. comma-separated values format).

-      Read all InventoryItem objects from the file and display them in tabular format including the projected total profit for each item and overall inventory as well.  

 

The following shows an example simple csv text file format. Each line represent an object’s data. 

 

12534,office chairs,75.0,100.0,25 

17654,coffee table,350.0,700.0,5 

18834,dining table,1500.0,2750.0,10 

14214,sofa set,2000.0,3500.0,7 

More products