Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Deliverables app.java , student.java and group.java as requested below. Contents Create an application that: Creates 4 students Build upon the solutions of the previous labs

Deliverables

app.java, student.java and group.java as requested below.

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

A method that displays the group name and the name of each student in the group

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:

Display the group name, and total group participation

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 thats what you have to learn with this lab)

See the examples in the lesson: video (Links to an external site.)Links to an external site.

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.

EDIT:

import java.util.Random;

class student{

String firstName = "John";

//constructor

student(String name){

this.firstName = name;

}

//getname method

public String getName() {

return this.firstName;

}

String[] behavior = {"writing","watching video lectures","solving problems",

"taking quiz", "reading", "coding java",

"applying for scholarships", "surfing", "interacting with peers",

};

int[] frequency = new int[9];

public String whatUp() {

//return random behavior

Random rand = new Random();

int number = rand.nextInt(behavior.length);

frequency[number]++;

return behavior[number];

}

public static void main(String args[]) {

student st1 = new student("John");

for(int i = 1; i <= 20; i++) {

System.out.println(st1.getName() + " is " + st1.whatUp());

}

for(int i = 0; i < 9; i++) {

float percent = (float)((float)st1.frequency[i]/(float)20) * 100;

System.out.println(st1.getName() + " was " + st1.behavior[i] + " " + percent + "% times.");

}

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming Languages 12th International Symposium Dbpl 2009 Lyon France August 2009 Proceedings Lncs 5708

Authors: Philippa Gardner ,Floris Geerts

2009th Edition

3642037925, 978-3642037924

More Books

Students also viewed these Databases questions

Question

4-6 Is there a digital divide? If so, why does it matter?

Answered: 1 week ago