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
Any file that contains data but not instructions for your computer is not considered software
DIA [1.3K]
True. 

But then again, partly false. A .deb file (Debian, Ubuntu Linux) contains data, but that data needs to be installed and marked executable to make the software.

But i would still say true.
5 0
3 years ago
Viết chương trình hoàn chỉnh các yêu cầu sau:
Blababa [14]

Explanation:

the perimeter of an aluminium sheet is 120 CM if its length is reduced by 10% and its breadth is increased by 20% the perimeter does not change find the measure of the length and the breadth of the sheet

4 0
3 years ago
Describe how serial data access finds data
jeyben [28]

Answer:

Serial data access will go through all the data by order until the target data is reached

Explanation:

This is opposite of direct data access which immediately finds the desired

data

4 0
3 years ago
Read 2 more answers
Give four examples of devices which are both<br>Input and Output to a Computer.​
myrzilka [38]

Answer:

HDMI ,I only have one answer to this question

4 0
3 years ago
As a result of 5G networks &amp; edge computing there will be an increasing number of different internet connection
vfiekz [6]

Explanation:

<h2><em><u>Edge computing with 5G creates tremendous opportunities in every industry. It brings computation and data storage closer to where data is generated, enabling better data control, reduced costs, faster insights and actions, and continuous operations. In fact, by 2025, 75% of enterprise data will be processed at the edge, compared to only 10% today.¹</u></em></h2><h2 /><h2><em><u>Edge computing with 5G creates tremendous opportunities in every industry. It brings computation and data storage closer to where data is generated, enabling better data control, reduced costs, faster insights and actions, and continuous operations. In fact, by 2025, 75% of enterprise data will be processed at the edge, compared to only 10% today.¹IBM provides an autonomous management offering that addresses the scale, variability and rate of change in edge environments. IBM also offers solutions to help communications companies modernize their networks and deliver new services at the edge.</u></em></h2>

Hope this answer is helpful

8 0
2 years ago
Other questions:
  • g Write a program to sort an array of 100,000 random elements using quicksort as follows: Sort the arrays using pivot as the mid
    7·1 answer
  • An expression that can’t be reduced any further is:
    5·2 answers
  • How do you do this question
    11·1 answer
  • To save a presentation, tap or click the save button on the Blank
    8·1 answer
  • The larger the Word Size of a computer
    6·1 answer
  • Statement Widgets or gadgets are _____ programs that appear on the desktop and display little pieces of information such as a ca
    5·1 answer
  • Explain what happens if you try to open a file for reading that does not exist.
    10·1 answer
  • Creation of ____________will help you to study the behavior of the real system
    11·1 answer
  • Recently, Walmart offered a wireless data contract based on bandwidth used, with a minimum monthly charge of $42 for up to 5 gig
    15·1 answer
  • What is one disadvantage people face without a checking account?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!