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
A fitness tracker can be classified as a wearable computer. true
Kay [80]
Depends, but I'd say false.
5 0
3 years ago
A spreadsheet has some values entered: Cell A1 contains 10, cell A2 contains 14, cell A3 contains 7. You enter in cell A4 the fo
Alinara [238K]
A1 is 10, so your answer is 10+2=12
B. 12
6 0
3 years ago
Read 2 more answers
What is the first step you should take when you want to open a savings account? A. Present your photo ID to the bank representat
lakkis [162]

Answer: B

Explanation:

6 0
3 years ago
Read 2 more answers
What is a positive and negative interface of Apple, Microsoft, Linux GUI
Vsevolod [243]

Answer:

Microsoft is perfect the only negative is their tech support

Apple is AMAZING but their software is confusing and doesn't let you customize

Linux GUI its good but its way behind in its time

Explanation:

3 0
3 years ago
Read 2 more answers
A father carries the Xga blood group trait and passes it on to all of his daughters, who express it, but to none of his sons. Th
Alecsey [184]

Answer:

The correct answer to the following question will be "X-linked dominant".

Explanation:

  • X-linked dominant inheritance, also referring to it as X-linked domination, is a hereditary inheritance process through which the X chromosome bears a dominant gene.
  • This is less prominent as a pattern of inheritance than the recessive type that is connected to the X.

Hence, the given statement would show the X-linked dominant form of inheritance sequence.

5 0
3 years ago
Other questions:
  • Using a database of precomputed hashes from sequentially calculated passwords called a(n) __________, an attacker can simply loo
    14·1 answer
  • Changing the user name in the word application is completed through the __.
    10·2 answers
  • trhy356<br>yjetyi46ui y j4yhnpug 2utg[ 2[ 24[ou [o24t
    15·1 answer
  • Missy creates a personal budget. She enters her current savings account balance in cell D3. In cell A3, she calculates her incom
    13·2 answers
  • What is an optical storage device?
    7·2 answers
  • What is the network id with cidr notation for the ip address 172.16.32.108 with the subnet mask 255.255.255.0?
    10·1 answer
  • 4. An advantage presented by straight-in spaces is that
    12·1 answer
  • What is a stored​ procedure?
    8·1 answer
  • If the three operations were combined, O(logN) + O(N) * O(logN) + 1, the overall algorithm cost would be:________
    6·1 answer
  • Which statement describes what the Conditional Formatting option in Excel 2016 allows users to do?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!