answer.
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
djyliett
1 month 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:
Rzqust [894]1 month ago
4 0

Answer:

The appropriate code for this query can be expressed as:

Code:

int lastVector = newScores.size() - 1; //define variable lastVector to store updated size of newScores.

newScores = oldScores; //assigning value.

for (i = 0; i < SCORES_SIZE - 1; i++) //initialize loop.

{  

newScores.at(i) = newScores.at(i + 1); //store value in newScores.

}

newScores.at(lastVector) = oldScores.at(0); //place first element at the end.

Explanation:

  • The provided C++ program contains two defined vector arrays, named "oldScores and newScores". The oldScores array contains elements "10, 20, 30, 40".
  • The snippet above shifts the first element from oldScores to the last position in newScores. To achieve this, an integer variable "lastVector" is created.  
  • This variable retains the size of newScores, and as such, all elements from oldScores are assigned to newScores. The loop involves using the at function to remove the first array element and append it to the end.
  • Lastly, a separate loop is used to print the elements of the newScores array.  

You might be interested in
Charlie has a large book collection. He was keeping track of it in a spreadsheet, but it has grown big enough that he wants to c
Harlamova29_29 [932]

Answer:

Review the explanation

Explanation:

Response 1) Keeping all data in a single row presents challenges; if one record in the sheet is deleted, all related records may also vanish unexpectedly. For instance, should the entry for author "James Taylor" be removed, all the books associated with him would get eliminated as well.

Response 2) In the first normal form (1NF), each row is supposed to have just one tuple, but in the case of the author "James Taylor," the title field contains two books, necessitating separation into distinct rows.

Response 3) The table shown in the image does not exhibit deletion anomalies; for the author "May Norton," if you erase this record, it will result only in the deletion of her sole book.

Thus, it’s essential to transition this table into the second normal form (2NF).

Create distinct tables for Authors and Books

Authors(Author Name, Author Country)

Books(Author Name, Book Title, Publisher, Publisher Location, Year, Price)

This cannot undergo further normalization.

3 0
1 month ago
Xem tập các tiến trình sau đây, với thời gian cần chạy ở cột Burst Time được cho ở đơn vị mili giây.
maria [879]
I can't comprehend this language; otherwise, I would assist you.
3 0
18 days ago
In cell F15, insert a function that will automatically display the word Discontinue if the value in cell D15 is less than 1500,
ivann1987 [930]

Answer:

=IF(D15<1500, "Discontinue", "No Change")

Explanation:

In an Excel environment, you should navigate to cell F15 and apply the IF function. The structure of the IF function is

IF(<condition>, <value if true>, <value if false>)

Your condition is placed before the first comma, which is D15 < 1500.

The second segment, located before the second comma, is the text to display when D15 is below 1500, which is "Discontinue".

Finally, the last part should show text if D15 is 1500 or higher, which is "No Change".

The complete formula can be expressed as =IF(D15<1500, "Discontinue", "No Change")

3 0
1 month ago
6. A small design agency you are consulting for will be creating client websites and wants to purchase a web server so they can
amid [800]

Answer:

Clarification:

The most effective recommendation for the agency would be to ensure they fully grasp the overall ownership costs of the server. This encompasses not only the server itself but also various factors including necessary software, an IT server manager, facility expenses, security investments, and backup options. Although these are key costs they will face, there may be additional unexpected expenses. Consequently, the best approach is to supply them with comprehensive information for making an informed decision.

3 0
18 days ago
A file concordance tracks the unique words in a file and their frequencies. Write a program that displays a concordance for a fi
oksian1 [797]

Answer:

Below is the Python code with suitable comments.

Explanation:

#Input file name acquisition

filename=input('Enter the input file name: ')

#Opening the input file

inputFile = open(filename,"r+")

#Dictionary definition.

list={}

#Read and split file content using a loop

for word in inputFile.read().split():

#Check if the word exists in the file.

if word not in list:

list[word] = 1

#Increment count by 1

else:

list[word] += 1

#Closing the file.

inputFile.close();

#Output a blank line

print();

#Sorting words according to their ASCII values.

for i in sorted(list):

#Display unique words along with their

#frequencies in alphabetical order.

print("{0} {1} ".format(i, list[i]));

3 0
1 month ago
Other questions:
  • Edhesive 2.3 code practice question 1​
    11·1 answer
  • Write a statement that reads a floating point value from standard input into temperature. Assume that temperature. has already b
    6·1 answer
  • Sarah works in a coffee house where she is responsible for keying in customer orders. A customer orders snacks and coffee, but l
    13·2 answers
  • for question 1-3, consider the following code what is output if the user types in 9? click all that apply A, B, C, D click all t
    13·1 answer
  • 7.7 LAB: Using a while loop countdown Write a program that takes in an integer in the range 10 to 100 as input. Your program sho
    11·1 answer
  • Henry, a graphic artist, wants to create posters. Which software should Henry use for this purpose?
    13·1 answer
  • In 2007, this wireless security algorithm was rendered useless by capturing packets and discovering the passkey in a matter of s
    6·2 answers
  • The ______ is the information center that drivers need to refer to when they're NOT scanning the road.
    7·1 answer
  • Danielle, a help desk technician, receives a call from a client. In a panic, he explains that he was using the Internet to resea
    9·1 answer
  • Explain what might happen if two stations are accidentally assigned the same hardware address?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!