double temp0, temp1, ..., temp29;
double[] temp = new double[30];
static private final int NUM_DAYS = 30; ... double[] temp = new double[NUM_DAYS];
temp[0] = 61.0;
temp[4] = 15.2;
System.out.println(temp[29]);Better:
System.out.println(temp[temp.length - 1]);In general, length is a (final) constant giving the size of the array
temp[temp.length - 1] = temp[0];
for(int day = 0; day < temp.length; day++) temp[day] = in.nextInt();
sum = 0; for each day add day's temperature to sum print sum / number of days
double sum = 0.0; for(int day = 0; day < temp.length; day++) sum += temp[day]; System.out.println("Average temp: " + (sum / temp.length));
double sum; sum = temp0 + temp1 + temp2 + ... + temp29;
element-type[] array-name = new element-type[length];
System.out.print("Enter number of names: "); int num_names = in.nextInt(); String[] names = new String[num_names]; for(int i = 0; i < num_names; i++) names[i] = in.next(); System.out.print("Names in reverse order:"); for(int i = num_names - 1; i >= 0; i--) System.out.println(names[i]);
inputs: max number of items to read, sentinel outputs: array (nums), actual count of items read pos = 0 // always: position to put next item read next while pos < items to read and next not= sentinel nums[pos] <- next pos <- pos + 1 read next actual_length <- pos
while pos < length and next not= sentinel nums[pos] <- next pos++ if pos < length then read next