Question: JAVA Question 1 Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end. Ex: If oldScores =
JAVA Question 1 Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end. Ex: If oldScores = {10, 20, 30, 40}, then newScores = {20, 30, 40, 10}.
public class StudentScores { public static void main (String [] args) { final int SCORES_SIZE = 4; int[] oldScores = new int[SCORES_SIZE]; int[] newScores = new int[SCORES_SIZE]; int i;
oldScores[0] = 10; oldScores[1] = 20; oldScores[2] = 30; oldScores[3] = 40;
/* Your solution goes here */
for (i = 0; i < newScores.length; ++i) { System.out.print(newScores[i] + " "); } System.out.println(); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
