Question
IT 2045C Computer Programming II Prof. Tom Wulf Fall 2021-22 Practicum 01 Java File IO and Safe Input review 20 points Learning Goals: Review Java
IT 2045C Computer Programming II Prof. Tom Wulf Fall 2021-22 Practicum 01 Java File IO and Safe Input review 20 points
Learning Goals:
Review Java text file IO
Be able to write programs that read and write java text files
Review the SafeInput library we developed in CP I. All our console programs will use this library
Write two suites of programs each with a reader and writer to create and read data files
Be sure to retain a copy of this and all work for the course. You will need these programs and files later as we work through the labs.
Note: we are switching to the IntelliJ editor this time. It will be used in future java courses so you should use it. If you see a reference to Netbeans use IntelliJ instead.
Directions:
Create a IntelliJ project using the filenames specified for both parts.
Do not create java packages here. Use the default package. That rule is for all assigned work!
Part 1: Person
Project Name: Person Model
Files: PersonGenerator.java, PersonReader.java, SafeInput.java Note: include and use SafeInput.java in both of these projects. (Be sure to place a separate copy within each of the project folders.) The SafeInput.java source file is available with the assignment directions in Bb, just download and include it in each project. Keep a copy handy with your work for use throughout the course. (We will review in class during the first week how to use SafeInput.)
Create a program (java main class) called PersonGenerator.java.
Your program will prompt the user to enter lines of data for a file on persons. You dont know ahead of time how many Persons will be entered so use an ArrayList to store the records.
Once the user indicates they have entered all the data elements for each person save it to a text file using a name they provided. (Be sure to only save complete sets of elements.)
Be sure to use the SafeInput library to completely bullet-proof your program. Block and repeat until the user gets the input correct. Do not terminate. INSERT SEVERAL SCREEN SHOTS SHOWING THE INPUT OF THE DATA. BE SURE TO GET ONE OF A COMPLETE RECORD.
Here is the data and file format. One record per line. Each line has all of the data elements (a e)
ID (a String)
FirstName
LastName
Title (a string like Mr., Mrs., Ms., Dr., etc.)
YearOfBirth (an int)
These files contain no headers. There is one person record per line in the comma-delimited format. Here is a sample record:
000001, Bilbo, Baggins, Esq., 1060
Be sure to test your program carefully.
Use your program to create a data file called PersonTestData.txt with these records: 000001, Bilbo, Baggins, Esq., 1060
000002, Frodo, Baggins, Esq., 1120
000003, Samwise, Gamgee, Esq., 1125
000004, Peregrin, Took, Esq., 1126
000005, Meridoc, Brandybuck, Esq., 1126
Leave a copy of the data file in the project folder, Please remove other test files. DISPLAY A SCREEN SHOT OF THIS FILE IN THE IntelliJ EDITOR HERE!
Part 2: PersonReader.java
Now create a new java main class in the same project called PersonReader.java.
Be sure to use JFileChooser and SafeInput.
Create a program that prompts the user to select an existing Person file and then displays the file to the screen.
Use your PersonTestData.txt file to test and debug your program.
Use String.format to create a neatly formatted columnar display of the data records
ID# Firstname Lastname Title YOB ===================================== 000001 Bilbo Baggins Esq. 1060
Frodo Baggins Esq. 1120
GET SCREENSHOTS OF: - THE FILECHOOSER RUNNING
THE DISPLAY OF THE CHOOSEN FILE
NEED FULL CODE THAT WORKS FOR JAVA (INTELLIJAVA)
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