subject

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();
}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 08:00, lindseyreneesmith7
Digital information is stored using a series of ones and zeros. computers are digital machines because they can only read information as on or off –1 or 0. this method of computation is known as the system
Answers: 1
image
Computers and Technology, 22.06.2019 19:10, hgdthbgjnb83661
What a backup plan that you have created in a event you encounter a situation
Answers: 2
image
Computers and Technology, 23.06.2019 12:00, deflox74
What does the level 1 topic in a word outline become in powerpoint? a. first-level bullet item b. slide title c. third-level bullet item d. second-level bullet item
Answers: 1
image
Computers and Technology, 23.06.2019 19:00, brittneyrenae7338
This question involves a class named textfile that represents a text file. public class textfile { private string filename; private string filename; private arraylist words; // constructors not shown // postcondition: returns the number of bytes in this file public int filesize() { } // precondition: 0 < = index < words. size() // postcondition: removes numwords words from the words arraylist beginning at // index. public void deletewords(int index, int numwords) { } // precondition: 0 < = index < = words. size() // postcondition: adds elements from newwords array to words arraylist beginning // at index. pub lic voidaddwords(int index, string[] newwords) { } // other methods not shown } complete the filesize() method. the filesize() is computed in bytes. in a text file, each character in each word counts as one byte. in addition, there is a space in between each word in the words arraylist, and each of those spaces also counts as one byte. for example, suppose the words arraylist stores the following words: { mary had a little lamb; its fleece was white as snow. } the filesize() method would compute 4 + 3 + 1 + 6 + 5 + 4 + 6 + 3 + 5 + 2 + 5 as the sum of the lengths of each string in the arraylist. the value returned would be this sum plus 10, because there would also be 10 spaces in between the 11 words. complete the filesize() method below: // postcondition: returns the number of bytes in this file public int filesize() { }
Answers: 1
You know the right answer?
10.8 zyLab: Print Roster Given a class called Student and a class called Course that contains an Ar...

Questions in other subjects: