Computers and Technology

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 Jones Marry 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.
Below is the code for the driver class - DriverMain. java
import java. util.*;
//Your program will be evaluated by this DriverMain class and several test case
public class DriverMain {
public static void main(String[] args) {
String name;
int rollNo;
int n = 0;
Student[] students = new Student[10];
ClassRoom classRoom = new ClassRoom();
Scanner input = new Scanner(System. in);
while(true){
name = input. nextLine();
if(name. equals(""))
break;
rollNo = Integer. parseInt(input. nextLine());
classRoom. addStudent(name, rollNo);
n++;
}
students = classRoom. getAllStudents();
for (int i = 0; i < n; i++) {
if(students[i]!=null)
System. out. print(students[i].getRollNo() + " - " + students[i].getName());
if (i < n - 1)
System. out. println();
}
}
}
//Below is the code for the Solution. java
// NOTE - THIS IS WHERE YOU WRITE THE CODE
import java. util.*;
class Student {
private String name;
private int rollNo;
public String getName() {}
public void setName(String name) {}
public int getRollNo() {}
public void setRollNo(int rollNo) {}
};
class ClassRoom {
private int i;
private Student[] students;
public void addStudent(String name, int rollNo) {
// WRITE YOUR CODE HERE
}
public Student[] getAllStudents() {
// WRITE YOUR CODE HERE
}
};

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 13:30, ashleypere99
Jane’s team is using the v-shaped model for their project. during the high-level design phase of the project, testers perform integration testing. what is the purpose of an integration test plan in the v-model of development? a. checks if the team has gathered all the requirements b. checks how the product interacts with external systems c. checks the flow of data in internal modules d. checks how the product works from the client side
Answers: 1
image
Computers and Technology, 23.06.2019 17:00, osirisarellane3792
*! 20 points! *jeff wants to create a website with interactive and dynamic content. which programming language will he use? a. dhtml b. html c. css d. javascript
Answers: 1
image
Computers and Technology, 23.06.2019 19:30, carcon2019
Amitha writes up a one-page summary of a novel during her summer internship at a publishing company. when she reads over the page, she realizes she used the word “foreshadow” seven times, and she would like to reduce the repetition. which tool would best amitha solve this problem?
Answers: 3
image
Computers and Technology, 24.06.2019 18:30, gucc4836
In what way is your social media footprint related to your digital id
Answers: 1
Do you know the correct answer?
Given a Student class, create a class with following characteristics: The class name should be Class...

Questions in other subjects:

Konu
Mathematics, 20.09.2021 04:00
Konu
Mathematics, 20.09.2021 04:00
Konu
History, 20.09.2021 04:00