
Concept explainers
Java
(The Course class) Revise the Course class as follows:
• Revise the getStudents() method to return an array whose length is the same as the number of students in the course. (Hint: create a new array and copy students to it.)
• The array size is fixed in Listing 10.6. Revise the addStudent method to automatically increase the array size if there is no room to add more students. This is done by creating a new larger array and copying the contents of the current array to it.
• Implement the dropStudent method.
• Add a new method named clear() that removes all students from the course.
Write a test program that creates a course, adds three students, removes one, and displays the students in the course
![LISTING 10.6 Course.java
1 public class Course {
2
private String courseName;
private String[] students = new String[100];
private int number0fStudents;
3
create students
4
public Course (String courseName) {
this.courseName = courseName;
6
add a course
7
9
public void addStudent (String student) {
students(number0fStudents] = student;
numberOfStudents++;
}
10
11
12
13
14
public String[ getStudents() {
15
return students
16
return students;
17
18
public int getNumber0fStudents(0 {
return number0fStudents;
19
number of students
20
21
22
public String getCourseName() {
return courseName;
23
24
25
26
public void dropStudent(String student) {
|/ Left as an exercise in Programming Exercise 10.9
27
28
29
}
30 }](https://content.bartleby.com/qna-images/question/f1782974-7f6f-4ae8-8de0-5b81c9f6f2aa/960ca8cd-b80b-45dd-b63d-b89e4210b035/jp8ykhp_thumbnail.png)

Trending nowThis is a popular solution!
Step by stepSolved in 5 steps

- In Java: Write a method that multiplies all elements in the array by 3 and returns it to the main method.arrow_forwardin javaarrow_forwardI need help with Chapter 10. Practice exercise 10.9 of the Introduction to Java 11 edition book. I tried using the textbook example but I got a few errors I couldn't figure out how to fix.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





