Given a Student class, create a class with following characteristics: The class name should be ClassRoom. Private variable students array to maintain the list of Student objects. Function addStudent with input parameter name (string) and rollNo(int) adds a new student in “students” list. Method getAllStudents should return all the students in ClassRoom. Input Jack 1 Jones 2 Marry 3 where, First & Second line represent a student’s name and roll number. And so on. Output 1 - Jack 2 - Jones 3 - Marry Assume that, Maximum “students” count can be 10. DriverMain.java and Solution.java attached.
Given a Student class, create a class with following characteristics: The class name should be ClassRoom. Private variable students array to maintain the list of Student objects. Function addStudent with input parameter name (string) and rollNo(int) adds a new student in “students” list. Method getAllStudents should return all the students in ClassRoom. Input Jack 1 Jones 2 Marry 3 where, First & Second line represent a student’s name and roll number. And so on. Output 1 - Jack 2 - Jones 3 - Marry Assume that, Maximum “students” count can be 10. DriverMain.java and Solution.java attached.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
--------------Answer question below:--------------
In Java:
Given a Student class, create a class with following characteristics:
- The class name should be ClassRoom.
- Private variable students array to maintain the list of Student objects.
- Function addStudent with input parameter name (string) and rollNo(int) adds a new student in “students” list.
- Method getAllStudents should return all the students in ClassRoom.
Input
Jack
1
Jones
2
Marry
3
where,
First & Second line represent a student’s name and roll number. And so on.
Output
1 - Jack
2 - Jones
3 - Marry
Assume that,
Maximum “students” count can be 10.
DriverMain.java and Solution.java attached.
![1- import java.util.*;
2
3 //Your program will be evaluated by this DriverMain class and several test cases.
4
5- public class DriverMain {
public static void main(String[] args) {
6-
7
string name;
int rollNo;
int n = e;
student[] students = new student[10];
10-
11
classRoom classRoom = new ClassRoom();
12
scanner input = new scanner (Ssystem.in);
13
while(true){
try{
name = input.nextline();
14
15
16
rollNO = Integer.parseInt(input.nextLine());
17
}catch(Exception e){
18
break;
19
20
if(name.equals("))
21
break;
22
23
classRoom.addstudent(name, rollNO);
24
n++;
25
students = classRoom.getAllstudents ();
for (int i = 0; i « n; i++) {
if(students[i]!=null)
26
27
28-
System.out.print(students[i].getRol1NO() +
+ students[i].getName ());
29-
if (i < n - 1)
30
31
System.out.println();
32
33
34 1](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fb266df41-1b07-4124-bae8-5b172638debd%2Fc2e6dfe3-1c1d-4698-8045-fca31385256c%2F3yh6sjg_processed.jpeg&w=3840&q=75)
Transcribed Image Text:1- import java.util.*;
2
3 //Your program will be evaluated by this DriverMain class and several test cases.
4
5- public class DriverMain {
public static void main(String[] args) {
6-
7
string name;
int rollNo;
int n = e;
student[] students = new student[10];
10-
11
classRoom classRoom = new ClassRoom();
12
scanner input = new scanner (Ssystem.in);
13
while(true){
try{
name = input.nextline();
14
15
16
rollNO = Integer.parseInt(input.nextLine());
17
}catch(Exception e){
18
break;
19
20
if(name.equals("))
21
break;
22
23
classRoom.addstudent(name, rollNO);
24
n++;
25
students = classRoom.getAllstudents ();
for (int i = 0; i « n; i++) {
if(students[i]!=null)
26
27
28-
System.out.print(students[i].getRol1NO() +
+ students[i].getName ());
29-
if (i < n - 1)
30
31
System.out.println();
32
33
34 1
![1- import java.util.*;
2
3- class student {
4
private string name;
5
private int rollNo;
7
public string getName() {
return name;
}
10
11-
public void setName (String name) {
12
this.name = name;
13
}
14
15-
public int getrollNo() {
16
return rollNo;
17
}
18
public void setrollNo(int rollNo) {
this.rollNO = rol1No;
19-
20
21
}
22 };
23
24 //Write your code in the ClassRoom Class
25
26 - class classRoom {
27
28
private int i;
29
private student[] students;
30
31
public void addstudent(string name, int rollNo) {
32
}
33
public student[] getAllstudents () {
}
35 };
34](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fb266df41-1b07-4124-bae8-5b172638debd%2Fc2e6dfe3-1c1d-4698-8045-fca31385256c%2Fqeqxcun_processed.jpeg&w=3840&q=75)
Transcribed Image Text:1- import java.util.*;
2
3- class student {
4
private string name;
5
private int rollNo;
7
public string getName() {
return name;
}
10
11-
public void setName (String name) {
12
this.name = name;
13
}
14
15-
public int getrollNo() {
16
return rollNo;
17
}
18
public void setrollNo(int rollNo) {
this.rollNO = rol1No;
19-
20
21
}
22 };
23
24 //Write your code in the ClassRoom Class
25
26 - class classRoom {
27
28
private int i;
29
private student[] students;
30
31
public void addstudent(string name, int rollNo) {
32
}
33
public student[] getAllstudents () {
}
35 };
34
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education