Revise the Course class as follows:? The array size is fixed in Listing 10.6. Improve it to
Question:
Revise the Course class as follows:? The array size is fixed in Listing 10.6. Improve it to automatically increase the array size 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
Transcribed Image Text:
1 public class Course { private String courseName; private String[] students = new String[100]; private int number0fStudents; 2 3 4 public Course(String courseName) { this.courseName = courseName; public void addStudent (String student) { students[numberOfStudents] = student; numberofStudents++; 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 } public String[] getStudents () { return students; public int getNumberOfStudents() { return number0fStudents; public String getCourseName () { return courseName; public void dropStudent(String student) { // Left as an exercise in Programming Exercise 10.9
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 57% (14 reviews)
Program Plan Define the class Course o Define the method addStudents Check the size of the array and ...View the full answer
Answered By
ANDREW KIPRUTO
Academic Writing Expert
I have over 7 years of research and application experience. I am trained and licensed to provide expertise in IT information, computer sciences related topics and other units like chemistry, Business, law, biology, biochemistry, and genetics. I'm a network and IT admin with +8 years of experience in all kind of environments.
I can help you in the following areas:
Networking
- Ethernet, Wireless Airmax and 802.11, fiber networks on GPON/GEPON and WDM
- Protocols and IP Services: VLANs, LACP, ACLs, VPNs, OSPF, BGP, RADIUS, PPPoE, DNS, Proxies, SNMP
- Vendors: MikroTik, Ubiquiti, Cisco, Juniper, HP, Dell, DrayTek, SMC, Zyxel, Furukawa Electric, and many more
- Monitoring Systems: PRTG, Zabbix, Whatsup Gold, TheDude, RRDtoo
Always available for new projects! Contact me for any inquiries
4.30+
1+ Reviews
10+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
a. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS 210), credit hours (for example, 3), and a letter grade (for example, A). Include get and set methods...
-
Create a CourseException class that extends Exception and whose constructor receives a String that holds a college courses department (for example, CIS), a course number (for example, 101), and a...
-
Revise the GenericStack class in Listing 19.1 to implement it using an array rather than an ArrayList. You should check the array size before adding a new element to the stack. If the array is full,...
-
A charged isolated metal sphere of diameter 10 cm has a potential of 8000 V relative to V = 0 at infinity. Calculate the energy density in the electric field near the surface of the sphere.
-
If your version of MATLAB has the flops command, use it to count the number of floating point operations to compute A-1 for a random 30 ( 30 matrix. Compare this number with the number of flops...
-
Which of the following compounds should have the larger energy barrier to internal rotation about the indicated bond? Explain your reasoning carefully. (CH3)3C-C(CH3)3 (CH3)3 Si-Si(CH3)3 A B
-
In 2014, Air Asia Flight No. 8501 crashed in the Java Sea while flying from Indonesia to Singapore. The crash resulted in the deaths of all passengers and crew on board. The plane involved in the...
-
For each of the following situations, indicate the amount of revenue that the government should recognize in an appropriate governmental fund as well as in its government-wide statement of activities...
-
How can a healthcare business increase its productivity and profitability using the disciplines found in Six Sigma?
-
Matilda Crone opened a public relations firm called Dance Fever on August 1, 2014. The following amounts summarize her business on August 31, 2014: During September 2014, the business completed the...
-
Section 10.6 gives a class for Stack. Design a class named Queue for storing integers. Like a stack, a queue holds elements. In a stack, the elements are retrieved in a last-in first-out fashion. In...
-
Write a program that prompts the user to enter a positive integer and displays all its smallest factors in decreasing order. For example, if the integer is 120, the smallest factors are displayed as...
-
People often sell goods (or raffle tickets) as part of a fund raising project. These projects typically offer valuable prizes to those who sell over a fixed number of units. Often a grand prize, like...
-
Oscar is 48 years old. He is married to Oliver. Oliver is 38 years old. During the current year of assessment Oscar earned the following income: interest from a tax-free investment of R40 000 and...
-
Bigger Company owns all of the issued capital of Smaller Company. The financial statements of Bigger Company and Smaller Company at 30 June 2023 are as follows: Bigger Company acquired its 100 per...
-
Your brother-in-law, Bil, fancies himself quite an investor, and he knows your sister, Hermana, also has "a bit of an interest in the markets." So, he wants you to settle a dispute between them as to...
-
Zabad is 33 years old. He is married to Zared. Zared is 26 years old. During the current year of assessment Zabad earned the following income: foreign dividends of R72 000 from a foreign company in...
-
3. A Domestic Corporation pays royalty to a Foreign Corporation but it withholds a tax lower than Philippine tax laws based on a treaty. What document need be presented to prove the imposition of a...
-
Valdez issues $450,000 of 13%, four-year bonds dated January 1, 2017, that pay interest semiannually on June 30 and December 31. They are issued at $493,608, and their market rate is 10% at the issue...
-
Revol Industries manufactures plastic bottles for the food industry. On average, Revol pays $76 per ton for its plastics. Revol's waste-disposal company has increased its waste-disposal charge to $57...
-
a. Write an application that allows a user to select one of at least five television shows to watch on demand. When the user selects a show, display a brief synopsis. Save the file as...
-
Design an application for the Sublime Sandwich Shop. The user makes sandwich order choices from list boxes, and the application displays the price. The user can choose from three main sandwich...
-
Write an application that allows a user to select a country from a list box that contains at least seven options. After the user makes a selection, display the countrys capital city. Save the file as...
-
You are working in an automotive workshop. Three (3) clients have brought in three (3) different vehicles that require diagnosis and repairs to the suspension systems and components. Your task is to...
-
5. Part 2: Torsion testing The aim of the torsion test is to find the shear modulus, yield and ultimate shear strength for the specimen material. Use the supplied dataset that matches with the LAST...
-
4. Part 1: Tensile testing The aim of the tensile test is to find the yield and ultimate tensile strengths and corresponding normal strains of the test material. This enables the prediction of the...
Study smarter with the SolutionInn App