Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you implement a system for storing the personal infortmation of stu- dents and teachers of a school in a comma-separated values (.csv)

image text in transcribedimage text in transcribed

In this assignment, you implement a system for storing the personal infortmation of stu- dents and teachers of a school in a comma-separated values (.csv) file 1 Problem Specification In order to implement the system, vou 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 1.1 Input Format User enters personal information of n students and teachers using the command line in the following format: Positioni Namei StudentID1 TeacherID1 Phonei Positiong Name, StudentID, TeacherID, Phone? Position3 Name3 StudentID3 TeacherID3 Phone3 Positionn Namen StudentIDn TeacherlDn Phonen Please note that the first line contains only an integer counting the number of lines 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. following the first line. StudentID and TeacherID must be a string of 5 digits . Phone is a string of 10 digits If the user enters an individual information in a wrong format, the method controlling the standard input stream must print a message on the screen asking the user to re-enter the individual 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 (); o int getID 0; 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 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

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

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions