You need to create a program that reads the input file items

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:

Solution

First create Item.java

Then, the Main class

Contents of items.txt

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

Sample output :

Contents of ex1out1.txt

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

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 outpu
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 outpu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site