Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a class called School. Include two private members representing the name

ID: 3883342 • Letter: C

Question

Create a class called School. Include two private members representing the name of the school and the number of students enrolled.

Create the appropriate accessors and mutators.

Create a default constructor that assigns the number of students to 100 and the school name to "unnamed" ,and a 2-arg constructor that will allow both attributes to be set form the declaration.

Create at least one instance using either constructor. The declarations should look as follows:

School udc, gtown("Georgetown University", 10500);

Explanation / Answer

import java.util.*;
class School{
private String schoolName;
private int numberStudents;
//constructor
public School(){
schoolName = "unnamed";
numberStudents = 100;
}
public School(String schoolName,int numberStudents){
this.schoolName = schoolName;
this.numberStudents = numberStudents;
}
//Accessors
public String getSchoolName(){
return schoolName;
}
public String getNumberStudents(){
return schoolName;
}
//Mutators
public void setSchoolName(String schoolName){
this.schoolName = schoolName;
}
public void setNumberStudents(int numberStudents){
this.numberStudents = numberStudents;
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote