Answer:
- public static void rotate4ints(int num1,int num2,int num3,int num4){
- int temp = num1;
- num1 = num4;
- int temp2 =num2;
- num2 = temp;
- int temp3 = num3;
- num3 = temp2;
- num4 = temp3;
- System.out.println("Rotated values "+num1+","+num2+","+num3+","+num4);
- }
Step-by-step explanation:
This is implemented in Java programming language
Aside the four int variables that will be rotated, three other teporary variables temp1-3 are created to hold temporary values while values are swapped
num1 gets assigned the value of num4, num2 gets assigned the value of num1, num3 gets assigned the value of num2 and num4 gets assigned the of num3.
Pay close attention to the use of the temp variables which are temporary holders of values in-order to swap their values
See a complete java program below with the output attached
public class num8 {
public static void main(String[] args) {
int num1 =15; int num2 = 47; int num3 = 6; int num4=23;
System.out.println("Original Arrangement");
System.out.println("Rotated values "+num1+","+num2+","+num3+","+num4);
System.out.println("After Rotation");
rotate4ints(num1,num2,num3,num4);
}
public static void rotate4ints(int num1,int num2,int num3,int num4){
int temp = num1;
num1 = num4;
int temp2 =num2;
num2 = temp;
int temp3 = num3;
num3 = temp2;
num4 = temp3;
System.out.println("Rotated values "+num1+","+num2+","+num3+","+num4);
}
}