1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ivann1987 [24]
3 years ago
15

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

0, 40}, then newScores = {20, 30, 40, 10}. Note: These activities may test code with different test values. This activity will perform two tests, the first with a 4-element array (newScores = {10, 20, 30, 40}), the second with a 1-element array (newScores = {199}).
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;
}
Computers and Technology
1 answer:
Anarel [89]3 years ago
4 0

Answer:

The code to this question can be given as:

Code:

int lastVector = newScores.size() -1; //define variable lastVector that holds updated size of newScores.

newScores = oldScores; //holds value.

for (i = 0; i < SCORES_SIZE - 1; i++) //define loop.

{  

newScores.at(i) = newScores.at(i+1); //holds value in newScores.

}

newScores.at(lastVector) = oldScores.at(0); //moving first element in last.

Explanation:

  • In the given C++ program there are two vector array is defined that are "oldScores and newScores". The oldScores array holds elements that are "10, 20, 30, 40".
  • In the above code, we remove the array element at first position and add it to the last position. To this process, an integer variable "lastVector" is defined.  
  • This variable holds the size of the newScores variable and uses and assigns all vector array elements from oldScores to newScores. In the loop, we use the at function the removes element form first position and add in the last position.
  • Then we use another for loop for print newScores array elements.  
You might be interested in
Which action deletes a row in a worksheet?
joja [24]

Answer:

C

Explanation:

st ryvyezrbubt5x3z3vubyc32 uvtxexyvuc4z26bux3x

5 0
3 years ago
Which of these problems is correct if the numbers are binary numbers?Group of answer choices1 + 1 = 21 + 1 = 100 + 0 = 11 + 0 =
Vinvika [58]

Answer:

The last one is correct.  

Explanation:

6 0
2 years ago
Windows, Apple’s Mac OS, and Unix/Linux are just some of the most common what?
34kurt
Most common PC operating systems
7 0
4 years ago
Read 2 more answers
Binary calculation of 1110÷101​
NemiM [27]
10.90 not sure tho. POWKSKS
3 0
3 years ago
Read 2 more answers
What is the purpose of using iteration or looping statements in a javascript code
Sonja [21]

In computer science, a loop is a programming structure that repeats a sequence of instructions until a specific condition is met. Programmers use loops to cycle through values, add sums of numbers, repeat functions, and many other things
Loops allow programs to perform repetitive tasks, such as iterating through an array, while adhering to the DRY principle (Don't Repeat Yourself). They come in handy when you want to execute a function a number of times, using different sets of inputs each time.
5 0
3 years ago
Other questions:
  • Several of the items below indicate the steps required to add a slide to a presentation. Select those steps and indicate the ord
    6·1 answer
  • The RGB value 0 is equal to "FF" in the HTML color code.
    9·1 answer
  • Programs such as word, excel, and PowerPoint are what type of tools
    11·1 answer
  • What is the main function of the motherboard?
    12·1 answer
  • For example, sumDigits(234) returns 9 (= 2 + 3 + 4). (Hint: Use the % operator to extract digits and the / operator to remove th
    15·1 answer
  • Mike wants to build an amplifier. which technology can he use?
    6·1 answer
  • Which of the following statements about federal student loans is true?
    7·1 answer
  • Suppose you are an ad-serving company and you maintain a log of cookie data for ads you serve to the Web pages for a particular
    14·1 answer
  • What is the full form of ARPANet, WAN,FTP,DCP,HTML,ISP and last WWW​
    12·2 answers
  • Which of the following is considered true regarding the future of technology?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!