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
Advocard [28]
2 years ago
8

What does the following code print?double[] myList = {1, 5, 5, 5, 5, 1};double max = myList[0];int indexOfMax = 0;for (int i = 1

; i < myList.length; i++) { if (myList[i] >= max) { max = myList[i]; indexOfMax = i; }}System.out.println(indexOfMax);
Computers and Technology
1 answer:
Liula [17]2 years ago
7 0

Answer:

This code will print: 4

Explanation:

Following is the step-by-step explanation for the given code:

  • Given is the array of data type double named myList, it has entries, 1, 5, 5, 5,5, 1:

                    double[] myList = {1, 5, 5, 5, 5, 1};

  • Now the first element of the array (1) with index 0 will be stored in the variable max (data type double).

                 double max = myList[0];  

  • A variable indexOfMax having datatype int will be initiated as 0.

                 int indexOfMax = 0;

  • Now for loop will be used to find the maximum number of the array. The variable i will be put as index for each element to compare with first element. If the checked element is greater than or equal to the integer in max, it will be replaced. So at the end the variable max will have value 5 that will be at index i = 4.

                    for (int i = 1; i < myList.length; i++)

                            { if (myList[i] >= max)

                               { max = myList[i];

  • Now the variable i that is the index for max value will be stored in the variable indexOfMax (indexOfMax = 4).

                  indexOfMax = i; }}

  • At end the value stored in variable indexOfMax will be printed, so 4 will be printed as output.

              System.out.println(indexOfMax);

i hope it will help you!

You might be interested in
Which option correctly identifies if the researcher’s approach was the best choice in the following scenario and explains why?
Tasya [4]

Answer:

A

Explanation:

go do it

4 0
3 years ago
Read 2 more answers
One of the most studied computational problems is the ordering of a collection of values. Ordering is important because many pro
andreyandreev [35.5K]

I think the order should be 2-1-3-4, but the description of step 1 is confusing. In selection sort, you iterate from the point of the marker down through the entire list and find the smallest value, and swap that with the value at the marker. Then you advance the marker and repeat the process on the remainder of the list.

7 0
3 years ago
In order to be an effective employee who knows recent information on loans and laws, in what topic should your information be cu
Paraphin [41]

Answer:

industry politics

Explanation:

In order to be an effective employee who knows recent information on loans and laws, your information should be current in industry politics.

This ultimately implies that, an employee who wants to be well-informed and knowledgeable on recent informations on loans and laws, is saddled with the responsibility of gathering and sourcing for informations through industry politics. Thus, the employee must have been involved in working with various industry leaders and most likely to have interacted with various employees working there.

Industry politics can be defined as a group of policies, standards and regulations set by the government to promote and facilitate competitiveness among the private and publicly owned industries.

6 0
2 years ago
Another name for a computer's operating system
nadya68 [22]

Answer:

core engine or system software.

Explanation:

just because

5 0
3 years ago
Read 2 more answers
How do I do a PowerPoint
kirill115 [55]
It is like this: . You just put a circle and that is a power point
4 0
3 years ago
Read 2 more answers
Other questions:
  • What item on a business card is generally the most prominent?
    13·2 answers
  • Is the cell phone changing our views about polite and impolite behavior? For example,
    15·2 answers
  • When designing your navigation, your primary objective should be to include keywords for search engines.
    6·1 answer
  • Which of the following should you consider when choosing a file format?
    9·2 answers
  • a. Daily Life Magazine wants an analysis of the demographic characteristics of its readers. The marketing department has collect
    13·1 answer
  • "True or False? Software designers use layering and other techniques to organize large software systems."
    13·1 answer
  • Use the drop-down menus to explain how to locate the Consolidate dialog box.
    6·1 answer
  • The ability to use various design software such as Adobe Photoshop, InDesign, and Illustrator would be MOST beneficial to which
    6·1 answer
  • State the functions of the parts of the computer​
    11·2 answers
  • A system administrator issues the command ps on a server that is running the Linux operating system. What is the purpose of this
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!