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
2. Which of the following statements accurately describes enzymes? A. Enzymes increase the activation energy of reactions. B. Te
Bas_tet [7]
B.temperatute and pH can affect how enzymes work
5 0
3 years ago
Why do amusement parks continue to build new roller coasters?
kykrilka [37]
They do it because they want people to experience new rides, instead of the same old boring rides they’ve been on several times.
5 0
3 years ago
Read 2 more answers
Based on the following passage on construction technology during the Middle Ages, why might a worker not be allowed to join a gu
olya-2409 [2.1K]

Answer:

He was not born into a family of skilled laborers

Explanation:

6 0
3 years ago
Angelina wants to modify the footer in her report so the page numbers are correct. To do this, she first double-clicks the foote
Mkey [24]

Answer:

Click Page Number, Click Current Position, Click Plain Number 1.

Explanation:

Just did it, e2020

4 0
3 years ago
(tco 3) what vbscript boolean operator could be used to replace the nested selection structure in this pseudocode? if empmedical
Leto [7]
You want both conditions to be true, so you can "And" them.
In vbscript, the and is written as "And" (not as && like other languages), so you get:

<span>If (empmedicalins = "y") And (empdentalins = "y") Then
    print empidnumber, emplastname, empfirstname
Endif</span>
3 0
3 years ago
Other questions:
  • When an object is selected, it is surrounded by ________, which allow you to change the size of the object.?
    5·1 answer
  • Which expense is a bank least likely to extend a line of credit for?
    13·2 answers
  • 3) An example of interactive web page is<br>​
    11·1 answer
  • ________ are used to translate each source code instruction into the appropriate machine language instruction.
    11·1 answer
  • Michale spent 80 minutes at the libary he finished studying at 4:00 what time did michale start studying
    8·1 answer
  • The color pattern in which marine organisms are light on the bottom and dark on the top of their bodies camouflaging them agains
    11·1 answer
  • Which of the following is not a type of Internet Job Board? Options Resume Blaster Professional Association Target Applicants We
    8·1 answer
  • If your machine is not used as a server and is not on a local network, what packet-filtering strategy should you use?A. Block al
    12·1 answer
  • Hi um... i just wanna say hi :P
    6·2 answers
  • With a(n) ____ you can arrive at a scene, acquire the data you need, and return to the lab as quickly as possible.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!