Q36. Write a program that reads in a sequence of ints into an array.
The program should the shift each value on one position in the array.
For example, whatever is in array position 4 should be moved into
position 5. Whatever is in the last position should be moved to the start.

//So we can start of by reading in 5 numbers in our array.

public static void main(String[] args) {
String strnum = "";
int[] numbers = new int [5];
int numsread = 0;


for (numsread = 0; numsread < numbers.length; numsread++){
strnum = JOptionPane.showInputDialog("Enter a Mark:");
numbers[numsread] = Integer.parseInt(strnum);}

//we need another temporary variable so we can swap them around one by one. We can use 'i' for this..

int i;

now i think we can start fiddling them around like so..//

i = numbers[4];
numbers[4]=numbers[3];
numbers[3]=numbers[2];
numbers[2]=numbers[1];
numbers[1]= numbers[0];
numbers[0] = i;


System.out.print(numbers[0]+ " ");
System.out.print(numbers[1]+ " ");
System.out.print(numbers[2]+ " ");
System.out.print(numbers[3]+ " ");
System.out.print(numbers[4]+ " ");
}}


Numbers entered: 5,10,15,20,25.

run:
25 5 10 15 20 BUILD SUCCESSFUL (total time: 13 seconds)