Answered step by step
Verified Expert Solution
Link Copied!

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 partially/completely re-enter the information that was previously entered in a wrong
format.
1.2 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 10-digit integer; while the Teacher class must have a phone variable of type int to
store only the 4-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:
getName()+,+getID()+,+ phone
1.3 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 (i.e. Name, ID and phone columns). Please note that you should be able to open
the output file of your program using MS-Excel and view it as a table.
2 Sample Input/Output
Assume that the user enters the following four lines in console: Teacher Alex,Martinez 0987653053489999
Student Rose,Gonzales 5678909876543210
TA John,Cruz 88888999991234567890
The program must write the following content in the out.csv file.
Alex Martinez, 98765,9999
Rose Gonzales,56789,9876543210
John Cruz, 99999,1234567890
3 Submissions
You need to submit a .zip file compressing the Java source file(s) of your program (.java
files).
students and teachers of a school in a comma-separated values (.csv) file.
1 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.
1.1 Input Format
User enters personal information of n students and teachers using the console in the following
format:
n
Position ?1 Name ?1 StudentID ?1 TeacherID Phone ?1
Position ?2Name2 StudentID 2 TeacherID Phone ?2
Position ?3Name3 StudentID 3 TeacherID 3 Phone ?3
...
Position ?n Name ?n StudentID ?n TeacherID ?n Phone ?n
Please note that the first line contains only an integer counting the number of lines
following the first line.
In each of the n 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 "0" or a string of 5 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 10 digits.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

Victoria v Emery s Warehouse

Answered: 1 week ago