1 Complete this simple program based on the following pseudocode: a. Prompt user to enter a value by printing, “How man
Posted: Sun May 15, 2022 1:42 pm
1 Complete this simple program based on the following
pseudocode:
a. Prompt user to enter a value by printing, “How many days'
temperatures do you
require?”
b. Based on the user input create an array named temps to store
this data
c. Inside a for loop collect temperatures form user one at the
time
d. In the same loop place these values in temps array using the [ ]
operator
e. In the same loop add all these temperatures as they are entered
and store them in
variable named int sum
f. Outside the loop, compute the average temperature for the entire
array
g. Display the average to user on console ("Average temp = %.1f\n",
average);
// Reads temperatures from the user, computes average and # days
above average
import java.util.*;
public class Weather {
public static void main(String []args) {
Scanner console = new Scanner(System.in);
// Your code goes here
}
2) Continue with the same program, this time add:
a) Use the Arrays.toString(temps) to display the array
b) Use the Arrays.sort(temps) to sort the values in the array
c) In a second for loop, iterate the entire array and determine the
two coldest days,
and the two hottest days. First think about where these values are
located after
sorting the array
d) Print out the result for user System.out.println(“The two
coldest days : “ +
<your logic>);
e) Print out the result for user System.out.println(“The two
hottest days : “ +
<your logic>);
pseudocode:
a. Prompt user to enter a value by printing, “How many days'
temperatures do you
require?”
b. Based on the user input create an array named temps to store
this data
c. Inside a for loop collect temperatures form user one at the
time
d. In the same loop place these values in temps array using the [ ]
operator
e. In the same loop add all these temperatures as they are entered
and store them in
variable named int sum
f. Outside the loop, compute the average temperature for the entire
array
g. Display the average to user on console ("Average temp = %.1f\n",
average);
// Reads temperatures from the user, computes average and # days
above average
import java.util.*;
public class Weather {
public static void main(String []args) {
Scanner console = new Scanner(System.in);
// Your code goes here
}
2) Continue with the same program, this time add:
a) Use the Arrays.toString(temps) to display the array
b) Use the Arrays.sort(temps) to sort the values in the array
c) In a second for loop, iterate the entire array and determine the
two coldest days,
and the two hottest days. First think about where these values are
located after
sorting the array
d) Print out the result for user System.out.println(“The two
coldest days : “ +
<your logic>);
e) Print out the result for user System.out.println(“The two
hottest days : “ +
<your logic>);