Write a Java program to do the following: A 10-element double array, called ref,
ID: 3640232 • Letter: W
Question
Write a Java program to do the following:A 10-element double array, called ref, holds the weekly reference temperatures used in a physical process. The process is run five days a week and the 10 temperatures actually observed in the process on a single day are recorded in an array called obs (number of elements in obs is 10). The elements in the two arrays have a one-to-one correspondence; e.g., ref[3] and obs[3] refer to the reference and observed temperatures of the same physical entity.
For a given day of the week, the total deviation (for all the 10 entities) of the observed values from the reference values is measured as the RMS (root mean squared) deviation:
daily total deviation = sqrt((1/10) * sum_{i= 1 to 10 elements} (ref[i] - obs[i])^{2}))
The program should simulate the RMS deviations for each of the five days of the week. For a given week, the reference temperatures are fixed (all five days of a given week have the same reference temperatures), but for two different
weeks they are different. The actual temperatures are observed and recorded daily.
Print the reference temperatures and the total RMS deviation for each of the five days of a given week.
The input to the program is an integer between 1 and 52 to indicate the week of the year. The outputs are
(i) the 10 reference values for the week and
(ii) 5 RMS deviations, one for each day of the given week.
Use the java random number generator Random and the method nextDouble() (as discussed in class) to obtain the temperature values. Use initial seed value(s) (don't use system-supplied seeds) so that different runs of your program with the same input
produce the same results (i.e., your program should produce exactly the same output when supplied with the same initial seed(s) and the same input). Note that ref[] and obs[] are one-dimensional arrays: do not make obs two-dimensional in an attempt to hold all 5 days. Use a loop for the five days of the week.
Explanation / Answer
public class Temperature { public static void main(String[] args) { char[] ref = createArray(); System.out.println("Enter a integer between 1 and 52 to indicate the week o f the year: "); displayArray(ref); int[] counts = countLetters(chars); System.out.println(); System.out.println("The 10 reference values for the week are: "); displayCounts(counts); public static char[] createArray() { char[] ref = new char[52]; for (int i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.