Question: JAVA. Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end. Ex: If oldScores = {10, 20,

JAVA. 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 = 0;

oldScores[0] = 10; oldScores[1] = 20; oldScores[2] = 30; oldScores[3] = 40;

/* Your solution goes here */

for (i = 0; i < SCORES_SIZE; ++i) { System.out.print(newScores[i] + " "); } System.out.println();

return; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!