public class Question6
1: //Question6.java
2:
3: import java.util.Scanner;
4:
5: public class Question6
6: {
7: public static void main(String[] args)
8: {
9: double[] array = new double[20];
10: Scanner keyboard = new Scanner(System.in);
11: System.out.println("Enter 20 numbers:");
12: for (int index = 0; index < array.length; index++)
13: array[index] = keyboard.nextDouble();
14: double lastNumber = array[array.length - 1];
15: System.out.println("The last number read is "
16: + lastNumber + ".");
17: System.out.println("The numbers read and their "
18: + "differences from last number are:");
19: for (int index = 0; index < array.length; index++)
20: System.out.println(array[index]
21: + " differs from the last number by "
22: + (array[index] - lastNumber));
23: }
24: }