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]
2 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]2 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]2 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
A spreadsheet is an interactive computer program used for
aksik [14]
Making charts, files that need complicated calculations
5 0
2 years ago
Click this link to view O NET'S Wages and Employment section for Film and Video Editors.
soldier1979 [14.2K]

Answer: much faster than average (11% or higher)

Explanation:

7 0
3 years ago
Read 2 more answers
A computing company is running a set of processes every day. Each process has its own start time and finish time, during which i
Helga [31]

Answer:

Above all else, let us show that this issue has the greedy choice property.

This implies that worldwide ideal arrangement can be gotten by choosing local ideal arrangements. Presently notice the following:

The global optimal solution of the issue requests us to track down the minimum number of times process_check module should be run.

It is likewise referenced that during each running interaction, process_check module should be called atleast once. Along these lines, the minimum possible number of process_check calls happens when process_check is made close to the quantity of the processes that are run.

Along these lines, we see that the global optimal solution is shaped by choosing optimal answer for the nearby advances.

Along these lines, the issue shows greedy choice property. Thus, we can utilize a greedy algorithm for this issue.

The greedy step in this calculation is to postpone the process_check as far as might be feasible. Thus, it should be run towards the finish of each interaction. So the following algorithm can be utilized:

Sort the cycles by utilizing the completion times.

Towards the finish of the 1st process in the arranged list, run the process_check module. Right now any process that is now running is removed the arranged rundown. The main interaction is additionally removed from the sorted list.

Now repeat stage 2, till all processes are finished.

In the above mentioned algorithm, the costliest advance is the step of sorting. By utilizing the optimal sorting algorithm, for example, merge sort, we can achieve it in O(n log n) asymptotic time.

Along these lines, this greedy algorithm additionally takes O(n log n) asymptotic time complexity.

5 0
2 years ago
What is thesql command to list the total sales by customer , month , and product, with subtotals by customer and by month and a
alexira [117]

Answer:

The answer is below

Explanation:

The the sql command to list the total sales by customer , month , and product, with subtotals by customer and by month and a grand total for all product sales is:

SELECT S.CUS_CODE, T.TM_MONTH, S.P_CODE,

SUM(S.SALE_UNITS*S.SALE_PRICE) AS "TOTSALES"

FROM DWDAYSALESFACT AS S INNER JOIN DWTIME AS T ON S.TM_ID =

T.TM_ID

GROUP BY S.CUS_CODE,T.TM_MONTH,S.P_CODE WITH ROLLUP;

4 0
2 years ago
Brainstorm what you want your LED board to do. What would need to happen first? What happens next?
lbvjy [14]
First it will glow then change what color you want
5 0
2 years ago
Read 2 more answers
Other questions:
  • MATLAB graphics user interface:<br> Describe what Folder, Command Window and Workspace are.
    5·1 answer
  • Read the scenario, and then answer the question that follows.
    10·1 answer
  • Your school computer library has a network that connects computers and devices within a few small rooms. what type of network do
    7·1 answer
  • How to make your keyboard sound like a piano?
    9·1 answer
  • 2. Use inheritance to create a hierarchy of Exception classes -- EndOfSentenceException, PunctuationException, and CommaExceptio
    6·1 answer
  • which of the following is a component of a rope-rewind starter system? a. a recoil spring c. an air vane governor b. a wrist pin
    5·1 answer
  • ________type of website is an interactive website kept constantly updated and relevant to the needs of its customers using a dat
    5·1 answer
  • Whats the correct answer
    15·2 answers
  • Compile and Execute a Program
    13·1 answer
  • Do you need a separate password for each slack channel
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!