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
Reil [10]
3 years ago
8

Write a loop that sets new scores to old scores shifted once left, with element 0 copied to the end. ex: if old scores = {10, 20

, 30, 40}, then newscores = {20, 30, 40, 10}.
Computers and Technology
2 answers:
olganol [36]3 years ago
5 0

For the given problem, define the size equal to 4 since four scores are given. Now, create two arrays: one for storing old score values and second for storing new score values. After this, assign old scores in an array and then create a loop that will shift the old score from second element until the one less than the size . Now, display the old scores and new scores as shown in output.

Further explanation:

Code:

The Java code to set the new scores from given old scores is as given below:

//Define the StudentScore class

public class StudentScores

{

//main method

public static void main(String[] args)

{

//Define final variable

final int SCORES_SIZE=4;

//Create two array

int[] oldScores = new int[SCORES_SIZE];

int[] newScores = new int[SCORES_SIZE];

//Declare a variable

int i = 0;

//Assign values to array

oldScores[0]=10;

oldScores[1]=20;

oldScores[2]=30;

oldScores[3]=40;

/*Your solution goes here*/

int firstOldScore=oldScores[0];

//Run for loop to shift the old score from second element until the one less than the size

for(int index=0;index<SCORES_SIZE-1;index++)

{

//shift oldScores to newScores

newScores[index]=oldScores[index+1];

}

newScores[SCORES_SIZE-1]=firstOldScore;

System.out.println("oldScores:");

for(i=0;i<SCORES_SIZE;++i)

{

// Display the oldScores

System.out.print(oldScores[i]+" ");

}

System.out.println();

// Print the new scores

System.out.println("newScores:");

for (i=0;i<SCORES_SIZE;++i)

{

//Display newScores

System.out.print(newScores[i] + " ");

}

System.out.println();

return;

}

}

Output:

oldScores:

10 20 30 40

newScores:

20 30 40 10

Learn more:

1. How does coding work on computers?  brainly.com/question/2257971

2. Prediction accuracy of a neural network depends on _______________ and ______________. brainly.com/question/10599832  

Answer details:

Grade: College Engineering

Subject: Computer Science

Chapter: Java Programming

Keyword:

Java, input, output, programming, statements,  char, int, variables, file, loop, old scores, new scores, array, size, variable, display

Inga [223]3 years ago
3 0

#include <iostream>
using namespace std;

int main() {
   const int SCORES_SIZE = 4;
   int oldScores[SCORES_SIZE];
   int newScores[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) {
      cout << newScores[i] <<" ";
   }
   cout << endl;

   return 0;
}

You might be interested in
Complete the following:_____
alexira [117]

Answer:

The answer to the give question as follows:

1) \n

2) \t

3) \'

4) \"

5) \\

Explanation:

The description of the above symbols as follows:

  • The \n is used to provide the new line spacing.
  • The \t is used to provide a tab space.
  • To assign a single character value we use \' single.
  • The double \" quote is used to assign a string value.
  • The backslash is used to provide the character of the escape and it also used in a file path.
7 0
3 years ago
What is the target audience of an ad?
GuDViN [60]

All ages

Explanation:

It is a toothpaste advert which most people use. It will also appeal to people who want to get whiter teeth

8 0
3 years ago
Computers are often referred to as _____.
GalinKa [24]
Smart machines I'm pretty sure
4 0
3 years ago
A researcher develops a new instrument to measure coping skills and conducts a pilot study to compare the new tool with an exist
alexira [117]

Answer:b)convergence.

Explanation: Convergence has the basic meaning as when two or more unit of anything meet to converge or join. In the research , the different types of the tools are brought togather and skills and compare them.The measurement is done through the tools which has the already defined parameters.

Thus this concept is the example of the convergence because the tools are being converged and compared.so, the correct answer is option (B) and other option are incorrect because they have the technique of the contrasting and separation and reading respectively.

3 0
3 years ago
What are the disadvantages of using grid analysis to help make decisions?
alekssr [168]

Answer:

Grid analysis is best used when a decision needs to consider multiple outcomes and different criteria. The format of this method however, can provide bias to a certain outcome. The process is only as good as the quality of information placed within the grid including the scoring. Once a factor is graded or placed subjectively, objectivity is compromised in this method. Also, this method keeps decision making strictly in a rational manner. But, it is considered unhealthy to be linear in decision making and one-sided. It is best to base decisions from a rational and take emotions into account as well.

7 0
2 years ago
Read 2 more answers
Other questions:
  • How can you tell if a hacker has administrative access?
    15·2 answers
  • To find a webpage, the user of a search engine would simply enter a word or phrase in the resource's text box. what is the term
    11·1 answer
  • pWhat macOS system application tracks each block on a volume to determine which blocks are in use and which ones are available t
    14·1 answer
  • What are some (free) good animation websites (for PC/Microsoft) for a short informational video about homelessness?
    15·1 answer
  • What two variables does mass depend on?
    5·1 answer
  • Assume phrase= "Peter Piper picked a peck of pickled peppers", What will be returned if phrase.search(/[aeiou]/) is called?
    9·1 answer
  • Do you think JNK should be more ethical?
    6·1 answer
  • Help pweaseee!! Lloyd has created a validation script for a data entry form. What property should he use to test for a selected
    10·1 answer
  • What is the difference between a crosstab query and a subquery?
    11·2 answers
  • Write a recursive function named canmakesum that takes a list of * integers and an integer target value (sum) and returns true i
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!