# CS526 Homework Assignment 1 solved

\$25.00

Original Work ?

## Description

This assignment has two parts and the goal of the assignment is:
 A practice of using basic Java features, including arrays, loops, selection statements, and
simple I/O.
 A practice of using Java’s linked list and writing a small interactive program.
Part 1 (40 points)
Create a file named ArrayConrolPractice.java and write the following methods in it:
 Write a Java method named sumOfEvenNumbers that receives an integer n and returns the
sum of all positive even integers less than or equal to n.
 Write a Java method named allDistinct that receives an array of integers and determines
whether all the integers are different from each other. The method returns true if all
numbers are different from each other and returns false otherwise.
 Write a Java method named statistics that receives an array of double numbers, calculates
the largest number, the smallest number, and the average of all numbers. The method, then,
stores these three statistics, in that order, in an array of size 3 and returns the array.

 Write a main method to test the above methods:
o Invoke sumOfEvenNumbers twice once with n =100 and then with n = 200, and
print each result on the screen.
o Create an array with 20 integers that include some duplicates, invoke allDistinct
and pass this array as an argument, and print the result on the screen. Repeat the
same but this time with an array with all distinct integers.
o Create an array with 10 double numbers, and invoke statistics and pass this array
as an argument, and print the result (max, min, average) on the screen. Repeat the
same with an array with different double numbers.
Part 2 (60 points)
Java’s LinkedList. Then, your program performs a few basic operations on the student list as
dictated by the user. Name your program StudentManagement.java. A Student class is already
defined and it is posted along with this assignment (do not use the Student class that comes with
the textbook). You should not modify the given Student class. As an example of a simple menudriven program, CarManagement.java file is also posted on Blackboard. You may want to study
this file before writing your program.
The requirements are given below:
Choose an option:
2. Remove a student
3. Update student GPA
4. Display student information
5. Display all students
6. Exit
If the user chooses option 1, your program performs the following:
 Prompts the user to enter a studentID, and reads it.
 If a student with the given studentID is already in the list, your program displays an
appropriate error message, and displays the main menu.
 Otherwise:
 Prompts the user to enter a name, and reads it.
 Prompts the user to enter a GPA, and reads it.
 Creates a student object and adds it to a LinkedList, displays an appropriate message
indicating a successful operation, and displays the main menu
If the user chooses option 2, your program performs the following:
 Prompts the user to enter a studentID, and reads it.
 If a student with the given studentID does not exist in the list, displays an appropriate
error message, and displays the main menu.
 Otherwise, removes the student with the given studentID from the list, displays
appropriate message indicating a successful operation, and displays the main menu.
If the user chooses option 3, your program performs the following:
 Prompts the user to enter a studentID, and reads it.
 If a student with the given studentID does not exist in the list, displays an appropriate
error message, and displays the main menu.
 Otherwise:
 Prompts the user to enter a GPA, and reads it
 Updates the GPA of the student with the new GPA, displays an appropriate message
indicating a successful operation, and displays the main menu.
If the user chooses option 4, your program performs the following:
 Prompts the user to enter a studentID, and reads it.
 If a student with the given studentID does not exist in the list, displays an appropriate
error message, and displays the main menu.
 Otherwise, displays the student information in the following format:
Name: John Smith
Student ID: U1234
GPA: 3.85
If the user chooses option 5, your program prints all students in the list in the following format:
Name: John Smith
Student ID: U1234
GPA: 3.85
Name: Susan Smith
Student ID: U2345
GPA: 3.92
. . .
If the user chooses option 6, your program terminates after displaying an appropriate message,
such as “Bye.”
Documentation
No separate documentation is needed. However, you must include sufficient inline comments
Deliverables
Submit your ArrayControlPractice.java and StudentManagement.java files to Blackboard.