Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a static method named instructions that takes a Random object and an integer parameter representing the number of minutes that a student is in

Write a static method named instructions that takes a Random object and an integer parameter representing the number of minutes that a student is in class and prints whether or not a student is listening for every 15 minutes. At the end of the method, you should return true if the students were listening 100% of the time, false if they were not listening at any time.

You will need to calculate the quarter-hour (15-minute) increments, making sure that if the division is not even, that you still report on the remaining minutes. For example, for the method call instructions(r, 35), there should be three lines of output (15, 15, 5); for the method call instructions(r, 10), there should be one line of output (10); for the method call instructions(r, 45), there should be three lines of output (15, 15, 15).

We will assume for this problem that when teachers give instructions to students, they don't listen about 25% of the time (a 1/4 likelihood of not listening). The method should use the Random object to select numbers in the range of 1 to 4 inclusive, where each number is equally likely to be chosen, for simulating the probability of students listening. If students are listening during the quarter-hour (15 minute increment), then "listening" should be printed to the screen. If the students were not listening, "not listening" should be printed to the screen.

just a static method no main no import.

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

Students also viewed these Databases questions

Question

9. Describe the characteristics of power.

Answered: 1 week ago