CIS 265 Data Structures and Algorithms Assignment 2 Due: 12:24pm, Tue, Feb. 9, 2021 100 points I. Description In this assignment, you will create a Java program to create an array of students to...

file attached


CIS 265 Data Structures and Algorithms Assignment 2 Due: 12:24pm, Tue, Feb. 9, 2021 100 points I. Description In this assignment, you will create a Java program to create an array of students to search. The program must implement a student class as specified in the following UML diagram. Student -name: String -id: int -gpa: double> +Student() > +Student(String, int, float) +pringStudent():void +getID():int 1. The program will first ask the user to input the number of students to be created. The number should be from 1 to 10. Otherwise, the program prints “I cannot create xxx students!” where xxx is the input number. 2. You must create an array of Student in the main method. The size of the array is decided by the number of students the user gives. Each element of the array will refer to a Student object. 3. The program then prompts the user to input details of each student including name, id, and gpa. It then uses Student’s constructor to create a Student object and assign it to an array element. 4. The Student class should have a constructor that takes a name, an id, and a gpa, to create a Student object. 5. The Student class should have a method printStudent() that prints the student’s name, id, and gpa, one per line. 6. After the input of the Student objects, the program will then search the student array. It keeps asking the user for a student ID. If the student ID is 0, the program will print “Goodbye!” and exit. Otherwise, the program will search the student array for the given student ID. If a match is found, the program will call printStudent() to print the student information. If no match is found, the program prints “Student ID xxxx not found.” where xxxx is the ID given by the user. 7. Since the student array may not be sorted, you should use linear search. 8. A sample run will look like this where the green texts are user inputs: How many students do you have(1-10): 4 Student 1 name:Anna Stomp Student 1 ID:1002 Student 1 GPA:2.3 Student 2 name:Elsa Ice Student 2 ID:1004 Student 2 GPA:3.2 Student 3 name:Paul Brown Student 3 ID:2201 Student 3 GPA:2.4 Student 4 name:Ice Frost Student 4 ID:4050 Student 4 GPA:1.2 Enter a student ID (enter 0 to quit): 1004 Student name:Elsa Ice Student ID:1004 Student GPA:3.2 Enter a student ID (enter 0 to quit): 2022 Student ID 2022 not found. Enter a student ID (enter 0 to quit): 0 Goodbye. II. General Requirements • Your program must include two Java files, one for the main class and the other for the Student class. • Both classes must be in the same package. The package name should start with your last name, e.g., FuCIS265. • Please name your main class file under your last name. For example, if your last name is “Fu”, your file name should start with “Fu”, e.g., FuAssignment3.java. • You can submit the source files • You can assume that user inputs are the correct format. Exception handling is optional. • The Scanner’s nextInt() method does NOT read the newline character. You need to call a nextLine() after nextInt() to discard the newline character. III. Submission This is an individual assignment. Each student needs to submit the source code files of the Java program on Blackboard. 1. You must submit both the main Java file and the Student Java file. You may submit them as individual files, or you can zip them and submit the .zip file. 2. You need to only submit the source code, i.e., the Java files. 3. You may submit multiple time. Your most recent submission before the deadline will be graded. IV. Grading 1. A program that does not run will receive 0 point. 2. There is a 10-20 points deduction for each major error, e.g., do not find a student. 3. There is a 1-9 points deduction for each minor error, e.g., a spelling error in printed message. 4. A program that does not follow the guidelines will lose 1-10 points. 5. Any type of cheating is not tolerated. You may be asked to explain your program in person. V. Bonus Feature (optional) If you implement any bonus feature in your program, please put a comment in your Blackboard submission and in your main Java file. (5 points) In the previous description, we assume user will not input duplicate student IDs. To ensure the uniqueness of student ID, the program can reject a student ID if it already exists. A sample run with this feature may look like this: How many students do you have(1-10): 3 Student 1 name:Winnie the Pooh Student 1 ID:1001 Student 1 GPA:3.2 Student 2 name:Tiger Kong Student 2 ID:1001 Student ID 1001 already exist! Please retry! Student 2 ID:1003 Student 2 GPA:2.1 Student 3 name:Purple Fun Student 3 ID:1003 Student ID 1003 already exist! Please retry! Student 3 ID:1001 Student ID 1001 already exist! Please retry! Student 3 ID:1005 Student 3 GPA:4.3 Enter a student ID (enter 0 to quit): 1001 Student name:Winnie the Pooh Student ID:1001 Student GPA:3.2 Enter a student ID (enter 0 to quit): 1002 Student ID 1002 not found. Enter a student ID (enter 0 to quit): 1003 Student name:Tiger Kong Student ID:1003 Student GPA:2.1 Enter a student ID (enter 0 to quit): 1005 Student name:Purple Fun Student ID:1005 Student GPA:4.3 Enter a student ID (enter 0 to quit): 0 Goodbye.
Feb 02, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here