Rewrite this program using and ArrayList. Assume that while entering temperatures from the keyboard -100 is the stopping condition. In other words, read temperatures from the keyboard until -100 temperature is entered. import java.util.Scanner; public class temp{ public static void main(String[] args) { Scanner scan = new Scanner(System.in); double[] tempereture = new double[31]; for(int i=0; i < tempereture.length ; i++) tempereture[i] = scan.nextDouble(); int maxIndex = 0; for(int i=0; i < tempereture.length ; i++) { if(temperature[i] > temperature[maxIndex]) maxIndex = i; } System.out.println("heighest temperature is " + temperature[maxIndex]); }}
Explanation / Answer
1) Average: int totalTemp = 0; int average = 0; for (int i=0; i