Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The whats up method is as follows: public String whatsUp() { String status = \"u

ID: 3664560 • Letter: T

Question

The whats up method is as follows:

public String whatsUp() {
  
        String status = "unknown";
  
        int statusNumber = (int)(Math.random() * 4);
      
        switch (statusNumber) {
      
            case 0:
              
                status = "surfing the web.";
                break;
          
            case 1:
              
                status = "talking.";
                break;

            case 2:
              
                status = "reading.";
                break;
        }

        return status;

Create an application that Creates 4 students Build upon the solutions of the previous labs (e.g., using app.java and student.java) o You will need a version of student.java that has a working whatsup() method Creates a group o First you have to design the new Java class called group A group has a name A group has 4 students Create a method in group.java that o displays the group name and the name of each student in the group in app.java o using the group variable (instance, object) in group.java o display information about what the third student in the group (retrieving information from the student class variables in the group, not from student variables in the app) is up to now (use the whatsUp() method). o For instance: "John" is "doing Java" o Pay attention, you have to use a the group variable (instance, object) in app.java o Something like System.out.println("the student is " + g1..); Suggestions o Start by creating a class called group with only one attribute, GROUP_NAME Make it work, using the app to display only the group name o Then you think how to add the students to the group (this is tricky..., but that's what you have to learn with this lab) o see the examples in the lesson

Explanation / Answer

public class StudentGroup {

public static void main(String[] args) {

if ((args.length == 0) || (args.length % 2) != 0) {

System.out.println("usage java StudentGroup [student names]"); }

else { StudentGroup.makeSomeStudents(args); } }

public static void makeSomeStudents(String[] arguments) {

CSStudent aStudent; int nextId = 0; for (int arg = 0; arg < arguments.length; arg++) {

// Each time through the loop a new CSStudent object is created and its reference is assigned to the aStudent field.

String name = arguments[arg];

String id = String.valueOf(nextId);

nextId++;

aStudent = new CSStudent( name, id);

aStudent.setGrade(100);

// Ask each Student to identify itself

System.out.println(aStudent); }