Question: You have been tasked with writing a Java program to manage a student database. You will be simulating a database by using an array of
You have been tasked with writing a Java program to manage a student database. You will be simulating a database by using an array of student objects but you will also be asked to write the data about the students to a text file and to reload the array from the text file. Guidelines:
Ensure that input validation is implemented where necessary eg valid ID nonempty name
Use appropriate exception handling to handle errors gracefully.
Document your code adequately with comments to explain the purpose of each method and significant sections of code
A maximum of students may be stored in the Student Object array.
The Student object will contain the following attributes:
Student ID Number integer number that is unique
Student Name string which may contain spaces but cannot be all spaces
GPA grade point average a floating point number between and
Last Student ID Number a static variable that contains the id number of the last student added to the database
The Student object will contain the following methods:
Constructor that loads data into the Student Object's attributes, the constructor should automatically assign the next available id number to the student using the Last Student ID Number field in the object
Method that will delete student record by setting string attributes to null and numeric attributes to zero based on the student id
Method that will load the object from data and update the Last Student ID Number if the current student's ID number is greater than Last Student ID Number value
Methods that will return each item of the student's data
Student Management program
This program is menu driven and will display a menu with the following functions:
Add Student: Add a new student to the database.
View All Students: Display information about all students in the database.
Search Student: Search for a student by their ID and display their information.
Delete Student: Delete a student from the database based on their ID
Save to File: Save the student database to a text file.
Load from File: Load student information from a text file into the database.
Exit the Program: Exit the program after displaying an exit message
Here is a brief description of each of the functions:
Add Student
This function will ask the user to enter the data about a student name and GPA The name field cannot be all blank and should be converted to upper case before storing in the object. Name should be entered as "last name, first name" and may contain spaces. The comma must be present in the name. The GPA field must contain a floating point number between zero and and have only one decimal point. When the student object is instantiated, the Last Student ID Number will be incremented by and the new value will be used as the Student Id Number. After the student has been added, display the ID number assigned to the new student and then the function will return to the menu.
View All Students
This function will process all entries in the array of student objects and display the information about each individual student in the array. The output should be formatted with a heading before the list of students and a total of the number of students processed at the end of the list. The list should appear as shown below with the fields aligned under the headings:
Student ID Student Name GPA
Smith, Mary
Jones, Fred
Van HoopleSmythe, Josephine
Total Students Displayed
After the display is complete, the function will return to the menu.
Search Student
This function will get the Student ID Number from the screen and search the object array for the matching Student ID Number. If found, the information about the student will be displayed. If not found, an error message will be displayed indicating that that Student ID Number does not exist. The student id number should be validated to make sure it is greater than and less than or equal to the current value of Last Student ID Number. After processing is complete, the function will return to the menu.
Delete Student
This function will get the Student ID number from the screen and search the object for the matching Student ID Number. If found, the information about the student will be displayed and the user will be asked if this is the student to be deleted. If the answer is yes, all numeric fields in the object will be set to zero and all strings will be set to null. A message will be displayed stating the student has been deleted. If the answer is no the function will return to the menu. If the student is not found, a message will be displayed that the student was not found and the function will return to the menu.
Save to File
This function wil
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
