Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

It is longer and involves writing two classes inside a BlueJ project. There are no early points for this assignment, but don't delay! Objective: Complete

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
It is longer and involves writing two classes inside a BlueJ project. There are no "early" points for this assignment, but don't delay! Objective: Complete and test a set of Java classes that keep track of student record information. You'll begin by downloading a BlueJ project named Assign10Records (available as a zip file from Canvas) which already contains a class with a ma in () method that you can use to test your work. Introduction The Registrar of UW-Parkside is responsible for keeping track of student records. Those records include personal information like names and student IDs, as well as a record of all the courses the student has taken. This information is used to generate transcripts, calculate who has made the Dean's list, find out if students have met the requirements for graduation, etc. etc. In reality, student records are stored in a database, which holds thousands of both current and past students. While Java works well with databases, this is an advanced topic, so we will use simple ASCII files and arrays instead. For this project, you will implement two classes from scratch: student and Registrar. The Student Class The Student class holds information about one student. To simplify the project, each student's data will include only four instance variables: 1. lastName, a String. The student's last name will be held within this String. Note: some students may have two names included here, separated by a space. 2. firstName, a String. The student's first name will be held within this String. Note: some students may have two names included here, separated by a space. 3. id, a String. This would hold a student identification number, and at UW-Parkside, we usually see this number with a letter at its beginning. We use a String to hold it since it is not used arithmetically. 4. gpa, a double. This holds the student's cumulative Grade Point Average (GPA). nclude the following instance methods in your class: 1. One constructor that takes four parameters: last name, first name, ID and gpa, in that order, 2. Four "getters" for each of the four data members, named getLastName (), getFirstName (), getID() and getgpa (). 3. tostring (): builds a String holding Student information that is suitable for use in printing reports, and returns that String. We want this method to concatenate information from each instance variable, with a space between each kind of data, and return that String. Design your String so that it looks this way: - The combined name (first name, followed by a space, then last name) should be left justified in a field of size 20 (how to left-justify explained below). - The ID is always exactly 9 characters long. - The gpa should be right justified with exactly 2 places to the right of the decimal point. For example, if Sam McGee is a student with ID "123456789" and a gpa of 3.25, this method would return a string that looked like: Sam McGee 1234567893.25 We have worked with System. out.printf () statements to do this kind of thing, but remember, you can also place the information in a String by using the String.format () method. For example: String s= "word"; String testFormat = string.format ("\%-8s", s); will place "word " into the String named testFormat. See how it is left-justified? The minus sign after the \% symbol makes it appear that way. Without the minus sign, all data will be right-justified. The Registrar Class The Registrar class contains an array of up to 100 Student objects. It will have two instance variables: 1. An array of Student objects (the constructor will instantiate his to size 100) 2. An integer that keeps track of how many positions in the array are filled (we did this in the example with the Fraction array). The Registrar class should contain the following public methods: 1. A constructor that takes the name of a data file as a String parameter and fills the array by reading information from that file. Add the words throws Exception after your constructor parameter ending ) symbol. Java requires this to handle potential bad filenames. (See how it is used with main () at end of this document.) The input file will have one student's data on each line, in the order: name, ID and gpa. You will need to use String methods to separate the name into the first and last names. The BlueJ project you copied included a file named students2. txt, which is a small sample file that holds this type of data. Open the file within an editor and examine how the lines appear. The student's name is written at the beginning of each line and included within double-quote marks, followed by the id number, followed by the GPA. More succinctly: - Positions 0-19 hold the student name. - Position 20 holds a blank. - Positions 21-29 hold the student id number. - Position 30 holds a blank. - Positions 31-34 hold the student GPA value. To separate the student name into first and last name, use String methods. You can use a method to find the comma; it appears just after the last name. So, the last name comes from all the characters (except the double-quote) before the comma, and the first name begins 2 positions after the comma (because there is a space after the comma, and neither the comma nor the space should be part of the first name). The first name should also not include the double-quote mark at the end of the name. 2. printList (): prints out all students using the Student class tostring () method. 3. printDeansList () : prints all students with gpas >= 3.5 , based on their gpa. Its format should be the same as for printList (). 4. findStudent (String lastName, String firstName): finds the student named in the arguments and prints their student information. If the student is not found, the method will print an error message instead. 5. findLastName (String lastName): finds all students with the last name given in the parameter and prints their student information. If no students are found with that last name, the method will print an error message instead. 6. addStudent () : prompts the user for all relevant information (in this sequence: last name, first name, id and gpa) and adds the student to the end of the array. If there is no room in the array, the method should print an appropriate error message. Your method does not need to check if a student already exists in the array; we assume that each student added really is new. You do not need to implement a method to delete students. Even if a student took one course in 1974 and dropped it, their record should still exist in the database. Test Data and Driver When you copy the BlueJ project, you'll see a file named students2, txt included. The students2 . txt file is a smaller file that you can use for testing. I'll use a larger, different file when I test your program. That is why your Registrar constructor needs the filename as a parameter

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

Students also viewed these Databases questions