1. Create a class named Student. Three private data fields for Student include an integer studentId, a String name, and a double finalMarks and one public final data field SIZE (5) that holds the maximum size of the array. Methods include a constructor that requires values for all three StudentId, name and finalMarks data fields, as well as get and set methods for each of these three data fields. Write a program named DemoStudent that declares an array of five Student objects. Using a loop, set each ID number to 9999, each name to XYZ and each marks value to zero. Display the Student objects. Save the files as Student.java and DemoStudent1.java. Modify the DemoStudent1 class so each Student has a successive ID number from 101 through 105, name XYZ that remains same and a marks value that ranges from 55 to 95 increasing by 10 for each successive Student. Save the file as DemoStudent2.java. 2. Next, modify the program that allows you to store an array that can hold any number of Student objects up to 5. Prompt the user for text input using JOptionPane.showInputDialog that asks "Do you want to Add objects (Press A) or Quit (Press Q)??” If user decides to quit, then, just exit. While the user decides to Add objects, call an addOption () method which proceed as follows: Generate an error message if the array is full. Otherwise, prompt the user for an ID number. If the ID number already exists in the array, issue an error message. Otherwise, prompt the user for a name value and a marks value and add the new object to the array. (For this portion, you can use Scanner class). Finally, display all Student objects using display() method. If number of objects in the array is two or more, call display_sorted() method which asks the user about choice of sorting objects by studentId or by name and then, display the student Objects in Sorted Order Save the application as DemoStudent3.java.
1. Create a class named Student. Three private data fields for Student include an integer studentId,
a String name, and a double finalMarks and one public final data field SIZE (5) that holds the
maximum size of the array. Methods include a constructor that requires values for all three
StudentId, name and finalMarks data fields, as well as get and set methods for each of these three
data fields. Write a
Using a loop, set each ID number to 9999, each name to XYZ and each marks value to zero.
Display the Student objects. Save the files as Student.java and DemoStudent1.java.
Modify the DemoStudent1 class so each Student has a successive ID number from 101 through
105, name XYZ that remains same and a marks value that ranges from 55 to 95 increasing by 10
for each successive Student. Save the file as DemoStudent2.java.
2. Next, modify the program that allows you to store an array that can hold any number of Student
objects up to 5. Prompt the user for text input using JOptionPane.showInputDialog that asks "Do
you want to Add objects (Press A) or Quit (Press Q)??”
If user decides to quit, then, just exit. While the user decides to Add objects, call an addOption ()
method which proceed as follows:
Generate an error message if the array is full. Otherwise, prompt the user for an ID number. If
the ID number already exists in the array, issue an error message. Otherwise, prompt the user
for a name value and a marks value and add the new object to the array. (For this portion, you
can use Scanner class). Finally, display all Student objects using display() method.
If number of objects in the array is two or more, call display_sorted() method which asks the
user about choice of sorting objects by studentId or by name and then, display the student
Objects in Sorted Order
Save the application as DemoStudent3.java.
Trending now
This is a popular solution!
Step by step
Solved in 7 steps with 9 images