Question: You need to create a program that reads the input file (items.txt), and store the items in the file in the Item array. After creating

You need to create a program that reads the input file (items.txt), and store the items in the file in the Item array. After creating that array, send the output to a new file ex1out1.txt

1) Construct the class named Item which will represent the record in item.txt and have it stored as a seperate file called Item.java. Class will contain

a) constructor that accepts item number and item name

b) setters and getters for them

c) toString() to print the values

Main program:

1)Name it "Main" and have it call the method step1 that contains the following:

a) reserve an array of size 10 for Item objects. call it itemArray.

b) Read "items.txt" file and store the records in the itemArray.

c) Write name and a blank line to an output file called "ex1out1.txt" and then the array in the reverse order like the following:

FirstName LastName

105 Hammer Large

104 Hammer Small

103 Nail #3

102 Nail #2

101 Nail #1

d) Now, add an ArrayList of Item class and name it itemArrayList.

e) In addition to reading "items.txt" file into itemArray, have records stored in the itemArrayList as well.

f) Now, print the contents of "itemArrayList" in order ( number-wise) to "ex1out1.txt" below the output of "itemArray"

Files:

items.txt:

101,Nail #1 102,Nail #2 103,Nail #3 104,Hammer Small 105,Hammer Large 

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!