Hello I am new to Java and I have no idea where to start with this program. Can somebody please start me off or display how you would execute the code. Thank you. This is what I have so far, but it is just the basics:
/*
* For each method, write the code clearly and concisely.
* The array, dht, contains the highest temperature reached each day for days 0, 1, ...
* dht.length = number of elements in array dht.
*/
public class Program1 {
private static int[] dht;
public static void main(String[] args) {
initialize();
System.out.println("highestTemp = " + highestTemp(dht));
System.out.print("hottestDay = " + hottestDay(dht));
// Add calls to remaining methods
}
public static void initialize() {
dht = new int[7]; // dht.length = 7
dht[0] = 41;
dht[1] = 68;
dht[2] = 77;
dht[3] = 74;
dht[4] = 74;
dht[5] = 68;
dht[6] = 88;
// Extra challenge - do the work of the initiazlize all
// in one Java statement.
}
/*
* Return the highest temperature reached during the recorded period.
* Don't print it out. Return it. For dht above, return 88.
* You may assume for this method and all others that
* temp.length >= 1
*/
public static int highestTemp( int[] temp ) {
// Fill in your code here
}
/*
* Return the index of hottest day. For dht above, return 6.
*/
public static int hottestDay( int[] temp ) {
// Fill in your code here
}
/*
* Count duplicate temperatures.
* For dht above, return 2. There is one duplicate each for 68 and 74.
*/
public static int countDuplicates( int[] temp) {
// Fill in your code here
}
/*
* Delete all duplicated temperatures. Compress the array to avoid
* gaps in the middle and pad out the array with the value -999 at the end.
* For dht above, change it to [41,68,77,74,88,-999,-999].
*/
public static void removeDuplicates( int[] temp ) {
// Fill in your code here
}
}