Computers and Technology

10.8 zyLab: Print Roster Given a class called Student and a class called Course that contains an ArrayList of Student. Write a method called printRoster() as described below.
Code:
import java. util.*;
import java. io.*;
/
* A list of students in a course
/
public class Course{
/** collection of Students */
private ArrayList roster;
/
Constructor for objects of class Course
/
public Course(){
roster = new ArrayList();
}
/
Use a for-each loop to print students one per line.
Use the provided toString() for Student.
Afterwords, print a final line that displays the
total number of students. For exampple:
First Last 3.2
First Last 2.5
First Last 4.0
Students: 3
/
public void printRoster(){
/** Your code goes here */

}

/
Add a student to the course
/
public void addStudent(Student s){
roster. add(s);
}

/
Main method for testing
/
public static void main(String args[]){
Course cis162 = new Course();
cis162.addStudent(new Student("Henry", "Cabot", 3.2));
cis162.addStudent(new Student("Brenda", "Stern", 3.2));
cis162.addStudent(new Student("Lynda", "Robison", 3.2));
cis162.addStudent(new Student("Jane", "Flynn", 3.2));
cis162.printRoster();
}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 22:10, Metlife
Asequential circuit contains a register of four flip-flops. initially a binary number n (0000 ≤ n ≤ 1100) is stored in the flip-flops. after a single clock pulse is applied to the circuit, the register should contain n + 0011. in other words, the function of the sequential circuit is to add 3 to the contents of a 4-bit register. design and implement this circuit using j-k flip-flops.
Answers: 1
image
Computers and Technology, 22.06.2019 23:30, elizabethburkha
Which text format is this, "the text is transcribed exactly as it sounds and includes all the utterances of the speakers. "?
Answers: 2
image
Computers and Technology, 24.06.2019 15:30, PresleyPie9452
George is working as a programming team lead. which statements correctly describe the skills that he requires?
Answers: 3
image
Computers and Technology, 24.06.2019 18:30, shemiahking5432
Jacking is a crime that takes place when a hacker misdirects url to a different site. the link itself looks safe, but the user is directed to an unsafe page
Answers: 1
Do you know the correct answer?
10.8 zyLab: Print Roster Given a class called Student and a class called Course that contains an Ar...

Questions in other subjects:

Konu
Mathematics, 15.07.2020 22:01
Konu
Mathematics, 15.07.2020 22:01