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
Please someone help!!!!
Montano1993 [528]

Answer:

do what the directions say and you should be able to figure out the answer if not contact me through brainly

Explanation:

3 0
3 years ago
write a 2d array c program that can capture marks of 15 students and display the maximum mark, the sum and average​
bekas [8.4K]

Answer:

#include <stdio.h>  

int MaxMark(int* arr, int size) {

   int maxMark = 0;

   if (size > 0) {

       maxMark = arr[0];

   }

   for (int i = 0; i < size; i++) {

       if (arr[i] > maxMark) {

           maxMark = arr[i];

       }

   }

   return maxMark;

}

int SumMarks(int* arr, int size) {

   int sum = 0;

   for (int i = 0; i < size; i++) {

       sum += arr[i];

   }

   return sum;

}

float AvgMark(int* arr, int size) {

   int sum = SumMarks(arr, size);

   return (float)sum / size;

}

int main()

{

   int student0[] = { 7, 5, 6, 9 };

   int student1[] = { 3, 7, 7 };

   int student2[] = { 2, 8, 6, 1, 6 };

   int* marks[] = { student0, student1, student2 };

   int nrMarks[] = { 4, 3, 5 };

   int nrStudents = sizeof(marks) / sizeof(marks[0]);

   for (int student = 0; student < nrStudents; student++) {              

       printf("Student %d: max=%d, sum=%d, avg=%.1f\n",  

           student,

           MaxMark(marks[student], nrMarks[student]),

           SumMarks(marks[student], nrMarks[student]),

           AvgMark(marks[student], nrMarks[student]));

   }

   return 0;

}

Explanation:

Here is an example using a jagged array. Extend it to 15 students yourself. One weak spot is counting the number of marks, you have to keep it in sync with the array size. This is always a problem in C and would better be solved with a more dynamic data structure.

If you need the marks to be float, you can change the types.

3 0
2 years ago
Tax preparation software can help prepare and file your taxes by _________.
OverLord2011 [107]
Tax preparation software can help prepare and file your taxes by April 15.
4 0
2 years ago
Favorite video games list atleast 5<br><br> favorite to least
Aneli [31]

Answer:

Rob lox, Sub nautica, Phasmo phobia, Albion Online,  fnf.

Explanation:

6 0
3 years ago
Consider the training requirements of a space operations specialist. The first step in the training process is obtaining a gener
Tamiku [17]

Answer:

Command Operations

Explanation:

Space Operation specialist requires special training for aircraft and its operations along with satellite controls. Initially when a graduate joins the training he is required to understand command operations of aircraft. He can then use his skills to learn command operation of spacecraft and then will be promoted to learn satellite controls.

6 0
2 years ago
Other questions:
  • Write a copy assignment operator for CarCounter that assigns objToCopy.carCount to the new objects's carCount, then returns *thi
    15·1 answer
  • What is a major plastics engineering project that is going on right now in Arizona?
    9·1 answer
  • A troubleshooter's ability to design and test hypotheses in order to solve a technology problem is based on ____.
    14·1 answer
  • Match the job titles to the tasks
    11·2 answers
  • You manage a server that users store their document files on. you are finding that some users are utilizing more space than they
    14·1 answer
  • Hat are three machines or devices that depend on gravity to work?
    5·1 answer
  • Please help me ASAP! Here is the question.
    15·1 answer
  • Alvin has created a non-extensive site map of all the commonly visited pages of his website. What is such a site map called?
    13·1 answer
  • Question 1(Multiple Choice Worth 5 points)
    9·2 answers
  • What is white light?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!