Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider a school that contains x number of students that all start their first period class in one of n classrooms. This scenario can be

Consider a school that containsx number of students that all start their first period class in one ofn classrooms. This scenario can be represented using three classes.

TheSchoolclass contains an ArrayList of all theClassrooms in the school. TheClassroom class has fields for the teacher in the room,teacherName, and an ArrayList of all the Students in the classroom,Students. TheStudent class has a field for the name of the student,studentName, and the ID number of the student,studentID.

TheSchool class contains a methodfindStudent that takes a teacher's name and a student ID as arguments and returns the name of the student. The method utilizes a sequential search algorithm to find the correct classroom and a binary search algorithm to find the correct student. If the student is not found in the school, the method returns "Student Not Found.".

Write/Include the completeSchool,Classroom, andStudent classes, including any instance variables, constructors, and necessary accessor methods. You may assume that the student ID numbers in each classroom are sorted in ascending order.

Here is the main method below

import java.util.*; public class ClassroomSearchTest { public static void main(String args[]) { ArrayList students = new ArrayList(); students.add(new Student("SpongeBob", 123)); students.add(new Student("Patrick", 143)); students.add(new Student("Squidward", 163)); students.add(new Student("Plankton", 183)); students.add(new Student("Pearl", 283)); ArrayList students2 = new ArrayList(); students2.add(new Student("Larry", 180)); students2.add(new Student("Squiliam", 200)); students2.add(new Student("Sandy", 243)); students2.add(new Student("Gary", 300)); students2.add(new Student("DoodleBob", 500)); ArrayList classes = new ArrayList(); classes.add( new Classroom("Mrs. Puff", students)); classes.add( new Classroom("Mr. Krabs", students2)); School spongebob = new School(classes); //findStudent Test System.out.println(spongebob.findStudent("Mrs. Puff", 123)); System.out.println(spongebob.findStudent("Mr. Krabs", 500)); System.out.println(spongebob.findStudent("Mrs. Puff", 223)); } }

Heres what I have right now

public class School { public static void main(String[] args) public int High; public int small; public static int School(int[]numbers , int high, int mid, int small){} } public int getStudent ID() return studentID; public String getStudentName() return studentName)_ /*classroomClass* */ private Stirng teacherName; private ArrayList Students; public classroom(String teacher, ArrayList){} teacherName = teacher; Student = theStudents;}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres the complete implementation of the School Classroom and Student classes including const... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

An Introduction To Statistical Methods And Data Analysis

Authors: R. Lyman Ott, Micheal T. Longnecker

7th Edition

1305269470, 978-1305465527, 1305465520, 978-1305269477

More Books

Students also viewed these Programming questions

Question

Define deferred revenue. Why is it a liability?

Answered: 1 week ago

Question

23. What are the effects of cannabinoids on neuronspg109

Answered: 1 week ago