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
Write a program that initializes a string variable and prints the first three characters, followed by three periods, and then th
d1i1m1o1n [39]

firstly we have to initialize the variable, means to give variable a value and then print the statement

string = "fahadisahadam"

print(string[:3]+"..."+string[-3:])

string is a data type that contains two or more characters.

means the string is fahadisahadam so the print will print first three characters. follow by three periods(...) and then last three characters.

The output will be:

fah...dam

8 0
3 years ago
Consider the code fragment below (with nested loops). int sum = 0;for (int i = 1; i &lt; 5; i++) for (int j = 1; j &lt;= i; j++)
sammy [17]

Answer:

Option d is the correct answer for the above question.

Explanation:

  • The first loop of the program has a second loop and then the statement. In this scenario, the second loop executes for the value of the first loop and the statement executes for the value of the second loop.
  • The first loop executes 4 times, Then the second loop or inner loop executes n times for the n iteration of the first loop, for example, 1 time for the first iteration of the first loop, 2 times for the second iteration of the first loop and so on.
  • Then the inner loop executes (1+2+3+4) iteration which gives the result 10 iterations.
  • The sum initial value is 0 and the "sum++", increase the value of the sum by 1.
  • So the value of the sum becomes 10 after completing 10 iterations of the inner for loop.
  • Hence the 10 will be the output. So the Option d is the correct answer while the other is not.
3 0
3 years ago
The numeric keys on a keyboard or calculator are referred to as a:
Anna [14]

Numeric Keypad is the answer

6 0
3 years ago
Where does an MPLS label go in a PDU?
Natalija [7]

Answer: Between Layers 2 and 3

Explanation:

In between Layer 2 and Layer 3 the MPLS header is present and is known as Shim header. It is also said to be in 2.5.

6 0
2 years ago
What should you do if a headset plugged into your computer is not working properly?
Alex777 [14]

If a headset plugged into computer is not working properly than one can go for updating the device driver. The correct option is B.

<h3>What is a device driver?</h3>

A device driver is a type of software application that allows one hardware device (such as a computer) to communicate with another hardware device (such as a printer). A device driver is indeed referred to as a software driver.

A driver, also known as a device driver, is a collection of files that instructs a piece of hardware on how to operate by communicating with a computer's operating system.

Every piece of hardware, from internal computer components like your graphics card to external peripherals like a printer, requires a driver.

If a headset plugged into a computer is not working properly, the device driver can be updated.

Thus, the correct option is B.

For more details regarding device driver, visit:

brainly.com/question/14054807

#SPJ12

8 0
11 months ago
Read 2 more answers
Other questions:
  • 25 POINTS + BRAINLIEST PLS HELPWhere should you put the argument for a command?
    13·1 answer
  • Brainly won't let me create an account even though i tried multiple emails and ages! It keeps saying "We're sorry, but we are no
    8·2 answers
  • Convert the binary number into a hexadecimal number.
    7·1 answer
  • Which devices typically generate computer output ?
    8·2 answers
  • Which of the following is a technique used by hackers to identify unsecured wireless network locations to other hackers?A. Blues
    10·1 answer
  • Cloud suites are stored on your hard drive and are available anywhere you can access the Internet
    15·1 answer
  • Which statement is true? Select 3 options.
    5·2 answers
  • Modify the Comments.java program from Programming Exercise 1-10 so at least one of the statements about comments is displayed in
    10·1 answer
  • Where are my files shortcut in documents folder.
    14·1 answer
  • A timer is set after each frame is sent before waiting an ACK for that frame, how long does the timer take to be expired?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!