Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

how can i make this class generateAvg return 0 before getting the average using observable? make it initially have no average 3+ import java.util.Observable;. 6

how can i make this class generateAvg return 0 before getting the average using observable?

make it initially have no average

image text in transcribed

3+ import java.util.Observable;. 6 public class generateAvg extends Observable { private int seed; double average = 0; private Random r = new Random(); 10 126 13 14 15 public generateAvg(int seed) { this. seed = seed; r.setSeed(this.seed); } 16 176 18 public double getAvg() { average = r.nextDouble()*10.0; return average; } 19 20 /** * Updates radiation, changes the state to true, and notifies all observers of * the change. 25 266 27 public void readRadiation() { setChanged(); notifyObservers(getAvg()); } 28 29 30 } }

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

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions

Question

1. Explain what is meant by ethical behavior.

Answered: 1 week ago