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
True or false? A medical assistant can check for available exam rooms and providers using an electronic scheduling system.
lutik1710 [3]
This is true m8 hope this helps
4 0
3 years ago
Is a three-prong grounding plug with the third pong broken-off safe to use.
ad-work [718]
What is the answer choices dude
8 0
3 years ago
What is the purpose of the Revisions pane in a presentation?
lana [24]
First option


Sorry if I’m wrong
7 0
3 years ago
Read 2 more answers
Or operator of boolean algebra is denoted by:<br>*<br>+<br>-<br>.​
OlgaM077 [116]

Answer:

or operator is denoted by + sign

7 0
3 years ago
You're the sole IT employee at your company. Most of the computers in your fleet are Windows machines. Your boss wants you to se
Gnesinka [82]

Answer:

The file service that should be used is HTTP SERVER

Explanation:

Below is a breakdown of different servers;

Samba server is used for LINUX platforms.

NFS is also used for UNIX / LINUX

Database server is used for only data storage purposes

HTTP SERVER can be used for network file storage by WIndows Systems.

The best option to adopt for file storage will be HTTP server

6 0
3 years ago
Other questions:
  • If you purchase a software suite for personal use, you can install the software how many times on how many different machines?
    6·1 answer
  • A compound document contains _______ from different applications.
    12·2 answers
  • Which tool is used to create an interactive web application?
    15·1 answer
  • What is a society that has moved to the internet Rather than relying on physical media called
    11·1 answer
  • FOR ALL PLATO USERS:
    10·2 answers
  • What does it mean when a computer can't break the rules
    10·2 answers
  • Question 21 pts How many lines should an email signature be? Group of answer choices "5 to 6" "7 to 8" "1 to 2" "3 to 4"
    10·1 answer
  • The metric unit used for length
    5·1 answer
  • Consider the following method.
    14·1 answer
  • What is this on G00gel Documents , how do I fix it?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!