Question: Lesson 2 Lab Assignment - Java: Random Behavior What Will You Learn Use of more sophisticated methods Use of random numbers Contents Using the classes

Lesson 2 Lab Assignment - Java: Random Behavior

What Will You Learn

Use of more sophisticated methods

Use of random numbers

Contents

Using the classes from Lab 1, app and student, create a solution for implementing some kind of random behavior for your student. Suppose the student can be reading, surfing the web, or interacting with other students. You will need to check now and then to see what the student is doing. You will be asking the instance of the student class and what it is doing at certain time intervals.

You Will Need To:

Create a method in the class student that returns what the student is doing.

Have this method generate the behavior randomly. It cant return the same thing every time.

Implement a for loop in the application to call for the student behavior 20 times.

In a 20 minute period, you are going to check once a minute = 20 times.

Give a total count for each activity.

Calculate and display the percentage, of the twenty behaviors displayed, spent on each activity.

NOTES:

Do not add any new attributes or variables to the student class.

The only change to the student class should be the addition of the method.

No need to work with TIME functions in Java. We are making a simulation as if every count of the for loop is one minute.

Generate a report in the end summarizing what the student did in class.

Example:

John is reading

John is reading

..

John is interacting with peers

John is surfing

---------------------------------------

Suggestions

If you need some help, see below for some suggestions:

My suggestion below is a step-by-step solution. Try to implement each step, one at a time.

Start with one of the examples from lesson 01. The new method whatsUp() is one more method in the student class. The student class should still have everything as before (first name, etc, getName() methods, same constructor).

Create a method called whatsUp( ) in the student class. This method is going to return what the student is doing in class. At first, make it return always the same thing, a string for instance, surfing the web." Later, I will suggest how to return different things.

Change the app. Include a for loop, such as:

for (int j = 0; j

If you made it here and read my example with random numbers above, try to change the whatsUp method so that it returns different behaviors randomly.

Use integer variables to count the number of times each activity occurs.

Use float variables to calculate the percentage. Lesson 2 Lab Assignment - Java: Random Behavior What Will You Learn

app.java u'ostudent.Java NetBeans Libraries My Net Output run: 1 Zack is taking quiz 2 Zack is taking quiz 3-Zack is reading 4 Zack is taking quiz S Zack is taking quiz 6 Zack is reading 7 Zack is coding Java 8 Zack is reading 9 Zack is taking quiz 10 Zack is reading 11 Zack is coding Java 12 Zack is reading 13 Zack is coding Java 14 Zack is coding Java 15 Zack is taking quiz 16 Zac is taking quiz 17 Zack is coding Java 18 Zack is taking quiz 19 Zack is reading 28 Zack is taking quiz Expected results ack was reading Zack was coding Java 25.0 of the tine Zack was taking quiz 45.0 of the tine BUILD SUCCESSFUL (total tine: seconds) me

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!