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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started