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
_____ are the supertiny on-off switches in a chip that work collectively to calculate or store things in memory. Transistors Mul
Pepsi [2]

Answer:

Transistors

Explanation:

4 0
2 years ago
Which of the following solutions enables simultaneous digital transmission of voice, video, data, and other network services ove
Annette [7]

Answer:

3. ISDN

Explanation:

ISDN ( Integrated Services Digital Network  ) -

It is the used for the simultaneous digital transmission of network service , data , video and voice , instead of the old circuits of the public switched telephone network ( PSTN ) , is referred to as ISDN .

The characteristic feature of ISDN is that it integrates the data and speech on the same lines , which is not possible in PSTN .

Hence, from the given information of the question,

The correct option is ISDN .

8 0
2 years ago
The amount of memory used by an array depends upon the array's data type and the number of elements in the array. True False
OverLord2011 [107]

Answer:

True

Explanation:

6 0
2 years ago
On laptops with a smart card reader installed, where is the smart card reader usually located?
dem82 [27]
Plenty of space in the palm rest
4 0
2 years ago
PLEASE HELP ME ASAP!!! THIS IS DUE SOON!!
KengaRu [80]

The below displays ice-creams with its associated flavours. This we would display using <UL>

• Stick

o Chocobar

o Feast

• Bowl

o Butterscotch

o Blueberry

<UL>

 <LI>Stick

  <UL>

  <LI>Chocobar </LI>

  <LI> feast</LI>

  </UL>

 </LI>

<LI>Bowl

  <UL>

  <LI> Butterscotch </LI>

  <LI> Blueberry </LI>

  </UL>

 </LI>

</UL>

Here <UL> tag is used to create un ordered list and one another <UL> tag inside <LI> created nested list which is the actual requirement. Like this we can created nested unordered lists and you can nest upto 4 levels and increasing the number of levels further may reduce clarity.

3 0
2 years ago
Other questions:
  • Yesterday Hunter's laptop screen appeared to go black. The laptop was still running, but he could not see the desktop or any gra
    9·1 answer
  • 1. Write a bash script to create 3 files of different size greater than 1700 kb and less than 1800 kb . The 2. Content of the fi
    9·1 answer
  • Hanging out with friends, watching your favorite TV show, and buying a pair of new shoes are all examples of _____ for doing wel
    5·2 answers
  • Python: Write a program that generates 8 random scores (between 0 and 100), store them in an array,
    8·1 answer
  • Create a java class for Bank Accounts with these public String attributes: ownerName, acctNbr and these private double attribute
    11·1 answer
  • The presentation layer describes the layer where computers interact with _____
    8·2 answers
  • )finding an unused location in the hash table is called
    5·1 answer
  • Mention two strategies of collecting data​
    13·1 answer
  • Why do you think Jacinda believed what people told her about her own beauty? Even if you understand that what you see on social
    13·1 answer
  • suppose one packet switches between a sending host and a receiving host. the transmission rates between the sending host and the
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!