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

Do not use any import java stuff.... very simple concepts The whatsUp method i u

ID: 3879992 • Letter: D

Question

Do not use any import java stuff.... very simple concepts

The whatsUp method i used was:

student.java

class student {

    private String _firstName;
    private String _lastName;
    private int _age;

    private String[] activities = {"taking quiz", "reading", "coding java", "eating a burguer",
        "drinking coffee"};
    private double totalActivityOne, totalActivityTwo, totalActivityThree,
            totalActivityFour, totalActivityFive;
    private int activityIterations;

    student(String firstName, String lastName) {

        _firstName = firstName;
        _lastName = lastName;
    }

    student(String firstName, String lastName, int age) {
        _firstName = firstName;
        _lastName = lastName;
        _age = age;
    }

    public String getFullName() {
        return _firstName + " " + _lastName;
    }

    public int getAge() {
        return _age;
    }

    public String whatsUp() {
        activityIterations = activityIterations + 1;
        String answer = activityIterations + " - " + _firstName + " is ";

        int randomNum = (int) (Math.random() * 5) + 1;

        switch (randomNum) {
            case 1:
                answer += activities[0];
                ++totalActivityOne;
                break;
            case 2:
                answer += activities[1];
                ++totalActivityTwo;
                break;
            case 3:
                answer += activities[2];
                ++totalActivityThree;
                break;
            case 4:
                answer += activities[3];
                ++totalActivityFour;
                break;
            case 5:
                answer += activities[4];
                ++totalActivityFive;
                break;
            default:
                break;
        }
        return answer;
    }

    public void outputActivityTotals() {
        double percentOfTotal = 0.0;

        percentOfTotal = (totalActivityOne / activityIterations) * 100;
        System.out.println(" " + _firstName + " was " + activities[0] + " "
                + percentOfTotal + "% of the time.");

        percentOfTotal = (totalActivityTwo / activityIterations) * 100;
        System.out.println(" " + _firstName + " was " + activities[1] + " "
                + percentOfTotal + "% of the time.");

        percentOfTotal = (totalActivityThree / activityIterations) * 100;
        System.out.println(" " + _firstName + " was " + activities[2] + " "
                + percentOfTotal + "% of the time.");

        percentOfTotal = (totalActivityFour / activityIterations) * 100;
        System.out.println(" " + _firstName + " was " + activities[3] + " "
                + percentOfTotal + "% of the time.");

        percentOfTotal = (totalActivityFive / activityIterations) * 100;
        System.out.println(" " + _firstName + " was " + activities[4] + " "
                + percentOfTotal + "% of the time.");
    }

}

app.java


public class app {

    public static void main(String args[]) {
        student st1 = new student("John", "Smith", 20);

        //Ouput 20 activities occurrences for the student
        for (int j = 0; j < 20; j++) {
            System.out.println(st1.whatsUp());
        }
        //Output the summanry of activities.
        st1.outputActivityTotals();
    }
}

Do not used all that information ...just need to use whatsUp method

Contents Create an application that: Creates 4 students Build upon the solutions of the previous labs (e.g., using app.java and student.java) You will need a version of student.java that has a working whatsup) method . Creates a group First, you have to design the new Java class called group A group has a name -A group has 4 students . Creates two methods in group.java 1. A method that displays the group name and the name of each student in the group 2. A method that displays the participation in a group. Participation is the sum of all the group members' (students) participation. Participation is an int number that varies from 1 to 10 (1 meaning very little participation, 10 meaning great participation). Participation starts in student using a random number (in a similar fashion of whatsUp)) to return the student's participation. For instance, when the method is called, we may have: student member #1, John, with a participation of 3: student #2, Mary, with a participation of 10; and student #3. Fred, with a participation of 5, which will give a participation of (3+10+5) -18 in app.java Using the group variable (instance, object) in group.java: 1. Display the group name, and total group participation 2. 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). For instance: "John" is "doing Java Pay attention, you have to use a the group variable (instance, object) in app.java . Something like System.out.println("the student is " + g1. ): Suggestions: . 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 Add the students to the group (this is tricky, but that's what you have to learn with this lab) . See the examples in the lesson: video a For Calculating Participation: . You will need a new method called participation in student.java . Start by copying the whatsUp) method in student.java to create a participation method in student.java. Make the necessary adjustments for it to return a number (it can be an int number from 1 to 10) . Then work on a participation method on group.java gathering participation from each student in the group . In the app.java create students and create a group (from previous labs and assignments), and then display the group participation.

Explanation / Answer

Here is the code for the whatsUp() method:

public int whatsUp(){

Random r = new Random();

int Low = 1;

int High = 11;

int participation = r.nextInt(High-Low) + Low;

return participation;

}

**Comment for any further queries.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote