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
What is wrong with the formula below?<br><br> SUM(A1:A5)/SUM(B1:B5)
Vlad [161]

Answer:

You forgot the "=" sign.

Explanation:

formulas in excel start with an "="

=SUM(A1:A5)/SUM(B1:B5)

4 0
4 years ago
Which of the following C++ statements displays a random number in the range 1 through 10?
lilavasa [31]

Answer:

Option(e)

Explanation:

rand() function results into a random number between 0 to a maximum number RAND_MAX which is a constant. To range it from 1, 1 is added and to decide its maximum value it should be modulo with that number. For example - if a number generated is 56 the 56%10 will be 6 which is in the range of 1 to 10. Option(a) is same as Option (b) because 1 is added and then subtracted which is neutral. Similarly, option (c) is also same.

7 0
3 years ago
Electronic mail is a
skad [1K]

Answer:

A) Transmission of letter, message and memos over a communication network

Explanation:

Communication can be defined as a process which typically involves the transfer of information from one person (sender) to another (recipient), through the use of semiotics, symbols and signs that are mutually understood by both parties. One of the most widely used communication channel or medium is e-mail (electronic mail).

An e-mail is an acronym for electronic mail and it is a software application or program designed to let users send texts and multimedia messages over the internet.

Hence, electronic mail is a transmission of letter, message and memos over a communication network. Some examples of the commonly used electronic mails platform are Yahoo, G-mail, etc.

5 0
3 years ago
Netiquette is the
e-lub [12.9K]

Answer:

C

Correct or acceptable way of communicating

4 0
3 years ago
Where do you want to install?
Fiesta28 [93]

This really depends on the thing you are trying to install, and the device you are trying to install it on.

try to find the app info and see what devices it is compatible with. make sure you are using a compatible device, and make sure you are signed in.

7 0
3 years ago
Other questions:
  • The problem solving process begins by first ______ the problem.
    11·1 answer
  • _____ is the network protocol that deals with the routing of packets through interconnected networks to the final destination.
    9·1 answer
  • Using the FAFSA form , you can for apply for what
    14·2 answers
  • What type of wireless connection requires an unobstructed "line of sight" between transmitter and receiver?
    8·1 answer
  • Why do we have to watch a video to get answers?
    7·2 answers
  • Write the definition of a class Clock. The class has no constructors and three instance variables. One is of type int called hou
    12·1 answer
  • The model for Diminishing Marginal Utility is ______ in nature.
    12·1 answer
  • A bubble starts by comparing the first item in the list to all the remaining items, and swaps where the first item is ____ a lat
    9·2 answers
  • PLEASE HELP. Nobody has been helping me, i need to resolve this code issue for game design
    8·1 answer
  • How can the absolute age of a rock be determined ?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!