Question

A College wants to build their Student Information Systems (SIS). Whenever a new Student is added...

A College wants to build their Student Information Systems (SIS). Whenever a new Student is added to the college, the details need to be recorded in a text file. Student information officer should be able to use the SIS to retrieve information from the text file and display it on the screen. The system also needs to be able to format or parse strings retrieved from the text file. I am using Eclipse IDE to write java code. Can I have help to develop the necessary design and implement the solution for the above given scenario. The solution must be able to serialize and/or de-serialize objects using the appropriate java APIs. You must document the Analysis and Design phases and submit the document with the artefact..

I

Please can I have Java code to implement this.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi,

Java code to implement the above-mentioned scenario.

and attaching a sample screenshot of output.

CODE:

package serialization;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class StudentInformationSystems {

   public static void main(String[] args) {
      
       // instantiates student with param constructor
       Student s = new Student("John", 1001);
       Student s1 = new Student("Martin", 1002);
       //creates list which stores student objects
       List<Student> list = new ArrayList<>();
       list.add(s);
       list.add(s1);
      
       //invoking write File method to write into a file
       writeFile(list);
      
       //invoke read file method to read from a file
       readFile();

   }

   //using serialization to write objects into file
   public static void writeFile(List<Student> studentList) {
       // using try with resources for closing resources implicitly after program
       // execution
       // creates the object of FileOutStream and specify the path where you want to store student details
       // creates the object of ObjectOutputStream
       try (FileOutputStream fos = new FileOutputStream("C:\studentData\student.txt");
               ObjectOutputStream oos = new ObjectOutputStream(fos)) {
           // Writes an object to a file
           oos.writeObject(studentList);
           System.out.println("student Object written to file successfully");

       } catch (IOException e) {
           e.printStackTrace();
       }
   }

   //method for deserialization to read objects from a file
   public static void readFile() {

       //creates list which stores Student Objects
       List<Student> studentList = new ArrayList<Student>();
      
       /*creates an instance of FileInputStream and give the path as argument
       from where you want to read data*/
       //creates the instance of ObjectInputStream
       try (FileInputStream fis = new FileInputStream("C:\studentData\student.txt");
           ObjectInputStream ois = new ObjectInputStream(fis)
       ) {
          
           //reads all objects from file and stores in a list
           studentList = (List<Student>) ois.readObject();
          
           //traversing through list to access student details
           for(Student s : studentList) {
               System.out.println(s);
           }
          
           System.out.println("data read successfully");
          
       } catch (IOException ioe) {
           ioe.printStackTrace();
           System.err.println("ERROR: " + ioe.getMessage());
       } catch (ClassNotFoundException cnfe) {
           System.err.println("ERROR: " + cnfe.getMessage());
       }

   }

}


//class which need to be serialized must implement Serializable interface
class Student implements Serializable {

   /*serialVersionUID will be used to verify that the sender and receiver of a serialized
   object have loaded classes for that object that are
   compatible with respect to serialization*/
   private static final long serialVersionUID = 1L;
  
   //add more attriutes according to scenario and change parameterized constructor accordingly
   private String studentName;
   private int studentId;

   public Student(String studentName, int studentId) {
       this.studentName = studentName;
       this.studentId = studentId;
   }
  
   public static long getSerialversionuid() {
       return serialVersionUID;
   }

   public String getStudentName() {
       return studentName;
   }

   public int getStudentId() {
       return studentId;
   }

   @Override
   public String toString() {
       // TODO Auto-generated method stub
       return studentName+" "+studentId;
   }

}


Add a comment
Know the answer?
Add Answer to:
A College wants to build their Student Information Systems (SIS). Whenever a new Student is added...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Code an application program that keeps track of student information at your college. Include their names,...

    Code an application program that keeps track of student information at your college. Include their names, identification numbers, and grade point averages in a fully encapsulated, homogeneous, linked-based binary search tree. When launched, the user will be presented with the following menu: Enter: 1 to insert a new student's information, 2 to fetch and output a student's information, 3 to delete a student's information, 4 to update a student's information, 5 to output all the student information in descending order,...

  • Information About This Project             In the realm of database processing, a flat file is a...

    Information About This Project             In the realm of database processing, a flat file is a text file that holds a table of records.             Here is the data file that is used in this project. The data is converted to comma    separated values ( CSV ) to allow easy reading into an array.                         Table: Consultants ID LName Fee Specialty 101 Roberts 3500 Media 102 Peters 2700 Accounting 103 Paul 1600 Media 104 Michael 2300 Web Design...

  • Principles of Computer Science

    Question First, you need to design, code in Java, test and document a base class, Student. The Student class will have the following information, and all of these should be defined as Private: A. Title of the student (eg Mr, Miss, Ms, Mrs etc) B. A first name (given name) C. A last name (family name/surname) D. Student number (ID) – an integer number (of type long) E. A date of birth (in day/month/year format – three ints) - (Do NOT use the Date class from...

  • A Chinese restaurant wants to have a computer-based search system that will display a recipe for...

    A Chinese restaurant wants to have a computer-based search system that will display a recipe for each dish. The owner of the restaurant wants the system to be flexible in that its recipes are stored in a text file. This way, the number of dishes can be expanded by adding more entries to the text file without changing any program code. After analyzing the coding the restaurant realizes that Current coding only outputs first two line of the recipe. Goal:...

  • Please run the program and show the result with screenshots after. Thank you (Java Eclipse) Customer...

    Please run the program and show the result with screenshots after. Thank you (Java Eclipse) Customer Data: Area Codes Assume you work for a company that tracks customer information, including name, gender and phone numbers Your company has a file called customers.txt which contains the following information: Jiming Wu F 4082123458 James Brown M 8315678432 Leanna Perez F 4087654433 Xing Li M 8313214555 Stacey Cahill O 8312123333 Mohammed Abbas M 4083134444 Kumari Chakrabarti F 4086667777 Shakil Smith M 4082123333 Jung...

  • I have already done the source code I just need help in the analysis part and design part asap Thank you File Edit View...

    I have already done the source code I just need help in the analysis part and design part asap Thank you File Edit View Windew Help ⑦ A Sign In Home Tools IT109N Assigmenx d share By completing this assignment, students should be able to: Assign expressions to variables Perfarm arithrietic calculations using Java Implement console user input/output in their programs . Use If clse statements to control the flow of logic in a program Computing Tax The United States...

  • Instructions This assignment has to be completed by each student individually. NO COLLABORATION I...

    I need help creating a class diagram for this please: I am not sure what more you want? it has 2 classes at least Connect4 and Connect4TextConsole. Instructions This assignment has to be completed by each student individually. NO COLLABORATION IS ALLOWED Submit YourASURitelD ProjectDeliverable2.zip compressed folder should contain the following files following This the 1. 2. Connect4.java 〔Game Logic Module) Connect4TextConsole.java (Console-based Ul to test the gamel 3. JavaDoc documentation files index.html and all other supporting files such as.cs5...

  • These tests are intended for undergraduate students in college or those under 18 years of age....

    These tests are intended for undergraduate students in college or those under 18 years of age. Read these directions carefully! The below test includes 10 questions, randomly selected from a large inventory. Most questions will be different each time you take the test, You must answer at least 9 out of 10 questions correctly to receive your Certificate. You have 40 minutes to complete each test, and you must answer all 10 questions in order to to see your results....

  • IN JAVA PLEASE HELP! ALSO PLEASE ADD COMMENTS Summary Build two classes (Fraction and Fraction Counter)...

    IN JAVA PLEASE HELP! ALSO PLEASE ADD COMMENTS Summary Build two classes (Fraction and Fraction Counter) and a Driver for use in counting the number of unique fractions read from a text file. We'll use the ArrayList class to store our list of unique Fraction Counters. Rather than designing a monolithic chunk of code in main like we did in the previous homework, we'll practice distributing our code into containers (called classes) that you will design specifically to tackle this...

  • I need help for part B and C 1) Create a new project in NetBeans called...

    I need help for part B and C 1) Create a new project in NetBeans called Lab6Inheritance. Add a new Java class to the project called Person. 2) The UML class diagram for Person is as follows: Person - name: String - id: int + Person( String name, int id) + getName(): String + getido: int + display(): void 3) Add fields to Person class. 4) Add the constructor and the getters to person class. 5) Add the display() method,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT