Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This program will use the Random class to generate random temperatures (integers) between some minimum (inclusive) and some maximum (inclusive) values. You will need to

image text in transcribedimage text in transcribedimage text in transcribed

This program will use the Random class to generate random temperatures (integers) between some minimum (inclusive) and some maximum (inclusive) values. You will need to calculate the minimum and maximum given a starting temperature integer and a possible change in temperature integer. (1) Copy the following method stub into your Temperature Predictor class and complete it according to the specifications described in the header comments. * Generates a random temperature (int) within a range when given the current temperature * and the possible temperature change inclusive. Example: for a temperature of 40 and a change of 5, the method should produce a random temperature between 35 and 45 inclusive @param rand The Random object * @param currTemp The current Temperature * @param change the possible change in temperature * @return A random value between the temperature-range and temperature range inclusive. public static int get Temp (Random rand, int currTemp, int changeInTemp) { //FILL IN BODY (2) Complete the main method using the following steps: . You should create an instance of a Random class (Random object) with a seed of Config.SEED. The instance will be passed to your method get Temp as the argument for the first parameter. Then, print out (each on their own line) the first 3 random temperatures generated by called get Temp with the Random object previously created, a current temperature of 65, and a possible change in temperature 10. When printing, use the following format "Temperature: 48 F", for example. Finally, print out two additional calls to getTemp (each on their own line) with different arguments. Try to think of arguments that might test the functionality of your getTemp method in different ways. Note that your arguments should be int literals. These additional calls should be place after the comment line: // Additional tests: ***DO NOT REMOVE THIS LINE*** The output for the first three calls should be: Temperature: 72 F Temperature: 61 F Temperature: 55 F For testing purposes, we require being able to predict the 'random' results. Setting a seed for the random number generator accomplishes this because it allows for a pseudo random number to be generated in a predictable order. For example, a seed of 85 for range of [3 to 9] may result in 4, 4, 9 for the first three values, while a seed of 2 for the same range may result in 5, 3, 4 for the first three values. With everyone using the same seed value, we are able to determine if your code produces the correct 'random' values. Without setting the seed, the results of the random number generator will always be different, making it impossible to verify that your code works. As discussed above in (2), Config.SEED is a constant named SEED declared in the Config.java file. Don't use the number in your Random Generator program, just use this constant. import java.util. Random; public class TemperaturePredictor { public static void main(String[] args) { //FILL IN BODY // Additional tests: ***DO NOT REMOVE THIS LINE***

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

Formal SQL Tuning For Oracle Databases Practical Efficiency Efficient Practice

Authors: Leonid Nossov ,Hanno Ernst ,Victor Chupis

1st Edition

3662570564, 978-3662570562

More Books

Students also viewed these Databases questions

Question

todo list using react native

Answered: 1 week ago

Question

What will you do or say to Anthony about this issue?

Answered: 1 week ago