Create a method in the class student that returns what the


Here's the prompt and I've included my code for what i've done so far at the bottom.

I need to figure out how to make the math.Random

statement output into behaviors (reading, writing, drawing)

You will need to:

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

2. this method have to generate the behavior randomly. It can't return the same thing every time.

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

1.) 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.

2. Change the app: include a for loop such as:

for (int j = 1; j < 20; j++)
{
// here, display what the student is doing using the whatsUp( ) method
// You should know how to do create an instance of a student,
// and display some basic information
}

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

public static void main(String[] args) {

String firstName1 = "Jon";
String lastName1 = "Snow";
double x;
//behavior = st.whatsUp();

for (int i=0; i x = Math.random();
System.out.println("My Random number" + x);
}
}
private String behavior (double x) {

return "hello";
}
}

if (behavior.matches("reading"))
{
i++;
}
if (behavior.matches("writing"))
{
j++;
}
if (behavior.matches("drawing"))
{
k++;

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Create a method in the class student that returns what the
Reference No:- TGS01420058

Now Priced at $10 (50% Discount)

Recommended (96%)

Rated (4.8/5)