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
Write an if-else statement for the following: If user_tickets is less than 5, assign 1 to num_tickets. Else, assign user_tickets
lesya [120]

Answer:

Please find the answer in the attached image.

Explanation:

I wrote this program using JavaScript programming language.

// A function to check tickets

function tickets(user_tickets){

var num_tickets;

if (user_tickets < 5) {

 num_tickets = 1;

 return ('num_tickets: '+ num_tickets);

}

else {

 num_tickets = user_tickets;

 return('num_tickets: '+ num_tickets);

}

}

// Testing the tickets function

// With user_tickets = 3, 5, 8, and 1

console.log(tickets(3));

console.log(tickets(5));

console.log(tickets(8));

console.log(tickets(1));

3 0
2 years ago
Show the steps of a Selection Sort for the numbers ( 5 3 9 5 ).
Sedbober [7]

Answer:

Sorted array will be:-

3 5 5 9

Explanation:

In Selection Sort algorithm it sorts the array by repeatedly finds the minimum in the array form the array that is unsorted and swaps it with the value at the first position.

The unsorted array:- 5 3 9 5

In first iteration

minimum is 3.

3 will be swapped with 5.

Now the array is 3 5 9 5

sorted array 3

In second iteration

unsorted array is 5 9 5

sorted array 3 5

and the minimum from it is 5

No swapping will occur.

In third iteration

unsorted array is 9 5

minimum is 5

sorted array 3 5 5

swap it with 9.

Now the array is sorted.

3 5 5 9

3 0
3 years ago
The ____ package contains frequently used classes and is implicitly imported into java programs.
Snowcat [4.5K]

Java.lang is the answer you're looking for

8 0
3 years ago
The idea that managers tend to communicate more with other managers who share similar beliefs and experiences is represented by
soldi70 [24.7K]

The idea that managers tend to communicate more with other managers who share similar beliefs and experiences is represented by all-channel network.

E. All-channel network

<u>Explanation:</u>

The manager wants to communicate with his or her staff. The manager has to use communication protocols either phone or mobile number or any IM software. In an organization if a manager wants to communicate by one to one or group member he or she has to will use any type of network.

Chain network: - flows up and down to communicate where anyone communicates to one to one or group chat.

Wheel network: - it is group admin communicates to his group members as one away communication, where group admin will communicate and another group just listen to group admin or leader. Same like online broadcasts methods

Circle network: - group members communicate with each other in the group. For example group concepts in online group member methods.

Groupware network:- where multiple end-user where communicate in a project related. This network exists until the project exists.  A particular groupware network is dismantling once the project is getting over or closed.

8 0
3 years ago
A positive return on investment for higher education.
lesya692 [45]

Answer: is when your earnings potential is higher than the cost of your education

Explanation:

A positive return on investment on a particular thing occurs when the benefit derived is more than the cost that was incurred while in a scenario whereby the cost is more than the benefit, a negative return on investment took place.

In this case, a positive return on investment for higher education occurs when your earnings potential is higher than the cost of your education.

5 0
2 years ago
Other questions:
  • Ten 9600-bps lines are to be multiplexed using TDM. a. Ignoring overhead bits in the TDM frame, what is the total capacity requi
    6·1 answer
  • To execute a prepared SQL statement, you can use the _______ and execute methods of the PDOStatement object to set parameter val
    9·1 answer
  • You can use the results from a search on a database in all of these ways except to ____.
    11·2 answers
  • On most computers, the default font size in Word is ____. 8 11 14 16
    6·1 answer
  • Technician a says that the above illustration shows one method used to keep the chain tension tight in an indirect drive camshaf
    8·2 answers
  • __________ offers a mechanism to accomplish four security goals: confidentiality, integrity, authentication, and nonrepudiation.
    9·1 answer
  • What should you rely on to determine when to change your oil? a. Oil color b. 6,000 miles since the last oil change c. Owners ma
    7·1 answer
  • _____________ describes the abstraction of web-based computers, resources, and services that system developers can utilize to im
    9·1 answer
  • One lap around a standard high-school running track is exactly 0.25 miles. Write the function miles_to_laps() that takes a numbe
    8·1 answer
  • I really need help in this!!!
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!