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
what you can do to increase your chances of getting employed with changes to your current digital footprint​
xxTIMURxx [149]
1) Show your work. Build an electronic portfolio, ideally on a website that you own, that shows the skills you have and the projects you have worked on. ,
2) Create a professional account on LinkedIn with your resume and recent photo. Connect with others there who can help you land a job.
3) Don't put anything on social media that would be embarrassing to you if your family found out or if it appeared in the newspaper or on the television news. Always assume that whatever you put online can be shared, no matter what the privacy setting is supposed to be.
4) Network with professionals who are doing the sort of work that you aspire to do. Ask thoughtful questions about the work that they do that you admire.
4 0
3 years ago
Which Windows installation method requires that you manually rename computers after the installation?​
levacccp [35]

Answer:

Command line

Explanation:

  • After installation of the machine one needs to manually rename the computer. This can be done through the start then settings, then system, and select rename the PC in the right-hand side column.
3 0
3 years ago
Which of the following mountain ranges stretches from Alabama to Canada?
Vikki [24]
The Appalachian Mountains
4 0
3 years ago
Which graphics format works best for desktop publishing and print work? (1 point) .tiff .gif .tga .jpeg?
Sergeeva-Olga [200]
. jpeg, probably works best
6 0
3 years ago
According to the SANS Institute, a __________ is typically a document that outlines specific requirements or rules that must be
nata0808 [166]
That’s should be in the quizlet I think..
7 0
3 years ago
Other questions:
  • What will be the output of “AAAAMMMMMHHHVV” using a file compression technique?
    9·2 answers
  • You are able to change the formatting of a table after it is inserted into a placeholder. True or false
    9·2 answers
  • A(n) _____ is a computer program that can damage files and programs on your computer.
    6·2 answers
  • Write a routine to interchange the mth and nth elements of a singly-linked list. You may assume that the ranks m and n are passe
    10·1 answer
  • #Write a function called alter_list. alter_list should have#two parameters: a list of strings and a list of integers.##The list
    11·1 answer
  • Which of the following could be a constructor for the public class MyClass? a. public MyClass() b. public void MyClass() c. publ
    7·1 answer
  • What spreadsheet tool could be used to add together the numbers in a<br> selected group of cells?
    10·1 answer
  • Complete the steps for adding a recurring event.
    10·1 answer
  • Guys, please help me asap (Photo Attached) !!!!!!! HELP 25pts!!!!
    14·2 answers
  • Question 2 of 25
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!