Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this assignment, you implement a program for storing the personal information of If the user enters information in a way that is not consistent
In this assignment, you implement a program for storing the personal information of If the user enters information in a way that is not consistent with the mentioned format, your
program must gracefully handle the situation by printing a message on the screen asking the
user to partiallycompletely reenter the information that was previously entered in a wrong
format.
Data Structure, Interface and Classes
Your program must have an interface called "CSVPrintable" containing the following three
methods:
String getName ;
int getID ;
void csvPrintln PrintWriter out;
You need to have two classes called "Student" and "Teacher" implementing CSVPrintable
interface and another class called TA extending Student class. Both Student and Teacher
classes must have appropriate variables to store Name and ID
In order to store Phone, Student class must have a phone variable of type long that can
store a digit integer; while the Teacher class must have a phone variable of type int to
store only the digit postfix of the phone number.
Method getName has to be implemented by both Student and Teacher classes in the
same way. Class Student must implement getID in a way that it returns the StudentID
and ignores the TeacherID given by the input. Class Teacher must implement getID in a
way that it returns the TeacherID and ignores the StudentID given by the input. Class TA
must override the Student implementation of getID so that it returns the maximum value of
StudentID and TeacherID.
Method csvPrintln has to be implemented by Student and Teacher classes and overridden
by TA class so that it writes the following string followed by a new line on the output stream
out:
getNamegetID phone
Output csv File
The program must store the personal information of students, teachers and TAs in a comma
separated values csv file called "out.csv You need to construct the output file by repet
itively calling the csvPrintln method of every CSVPrintable object instantiated in your
program. The output csv file stores the information of every individual in a separate row;
while each column of the file stores different type of information regarding the students and
teachers ie Name, ID and phone columns Please note that you should be able to open
the output file of your program using MSExcel and view it as a table.
Sample InputOutput
Assume that the user enters the following four lines in console: Teacher Alex,Martinez
Student Rose,Gonzales
TA John,Cruz
The program must write the following content in the out.csv file.
Alex Martinez,
Rose Gonzales,
John Cruz,
Submissions
You need to submit a zip file compressing the Java source files of your program java
files
students and teachers of a school in a commaseparated values csv file.
Problem Specification
In order to implement the system, you need to write a java program that gets the personal
information of individuals from the console and store it in different rows of the output csv
file.
Input Format
User enters personal information of students and teachers using the console in the following
format:
Position Name StudentID TeacherID Phone
Position StudentID TeacherID Phone
Position StudentID TeacherID Phone
Position Name StudentID TeacherID Phone
Please note that the first line contains only an integer counting the number of lines
following the first line.
In each of the given input lines,
Position must be one of the following three strings "student", "teacher", or TA
Name must be a string of two words separated by a single comma only.
StudentID and TeacherID must be either or a string of digits. If Position is
"teacher", StudentID is zero, but TeacherID is not zero. If Position is "student",
TeacherID is zero, but StudentID is not zero. If Position is TA neither StudentID
nor TeacherID are zero.
Phone is a string of digits.
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