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
viktelen [127]
3 years ago
5

Write a program that prompts the user to enter the number of integer numbers you need to enter, then ask user to enter these int

eger numbers. Your program should contain an indexOfLargestElement method, which is used to return the index of the largest element in an array of integers.
Computers and Technology
1 answer:
nadya68 [22]3 years ago
8 0

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

 Scanner ob = new Scanner(System.in);

 System.out.println("How many numbers? ");

 int n = ob.nextInt();

       int[] arr = new int[n];  

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

     System.out.print("Enter the number: ");

     arr[i] = ob.nextInt();

 }

    System.out.println(indexOfLargestElement(arr));

}

public static int indexOfLargestElement(int[] arr) {

    int max = arr[0];

    int maxIndex = 0;

    for (int i=0; i<arr.length; i++) {

        if (arr[i] >= max) {

            max = arr[i];

            maxIndex = i;

        }

    }

    return maxIndex;

}

}

Explanation:

Create a method called indexOfLargestElement that takes one parameter, an array

Initialize the max and maxIndex

Create a for loop iterates throgh the array

Check each element and find the maximum and its index

Return the index

Inside the main:

Ask the user to enter how many numbers they want to put in array

Get the numbers using a for loop and put them inside the array

Call the indexOfLargestElement method to find the index of the largest element in the array

You might be interested in
What should not be compromised when trying to meet standards and deadlines?
n200080 [17]
A i believe is the answer
5 0
3 years ago
In the Happy Valley School System, children are classified by age as follows: less than 2, ineligible 2, toddler 3-5, early chil
sasho [114]

// C++ switch

// It can also be used for JAVA, C#

switch(age){

// here age will be sent by the function in which it is used

// case to check the age<2

case(age<2 && age>0):

// printing the line

cout<<"ineligible";

// case to check the age ==2

case(age==2):

// printing the line

cout<<"toddler";

// case to check 3-5

case(age>=3 && age<=5):

cout<<"early childhood";

// case to check 6-7

case(age==6 || age==7):

cout<<"young reader";

//case to check 8-10

case(age>=8 && age<=10):

cout<<"elementary";

// case to check 13

case(age==13):

cout<<"impossible";

//case tocheck 14-16

case(age>=14 && age<=16):

cout<<"high school";

// case to check 17 or 18

case(age==17 || age==18):

cout<<"scholar";

//case to check >18

case(age>18);

cout<<"ineligible";

// default case

default:

cout<<"Invalid age";

}

Read more on Brainly.com - brainly.com/question/12981906#readmore

5 0
3 years ago
There is no need to schedule video calls ahead of time; they can be used the same way as
UNO [17]

Answer:

The answer to this question is "True".

Explanation:

The term video calling is part of communication. In this type of communication will be used in every place like house, office for video conferencing, etc. It was developed in 1968 by AT&T's Bell Labs. It works on internet.This type of calling we can face to face communicate means, we watch the person. In the video calling, there is no need for a schedule it is used as a phone call.  

6 0
3 years ago
Complete the program segment below to write the numbers 1 through 50 to the numbers.txt file.
Ludmilka [50]

Answer:Usisksk

Explanation:

Js JSU’s

8 0
3 years ago
Wat kind o mouse pleese hep meh​
Trava [24]

Answer:

It's is a razer Basilisk

4 0
3 years ago
Other questions:
  • In every organization, workers receive and sendinformation daily. The flow of this information should be____________.upward and
    11·1 answer
  • A) Write 600 as the product of prime factors.<br> Give your answer in index form.
    7·2 answers
  • If a client is found _________ the NAP will attempt to make it _______. Group of answer choices A. non-compliant, compliant B. s
    13·2 answers
  • The birthday problem is as follows: given a group of n people in a room, what is the probability that two or more of them have t
    12·1 answer
  • Which of the following substances increases in quantity during repititive muscle contraction during oxygen deficti ?
    11·1 answer
  • What is the meaning of <br>computer<br>viruses ?​
    8·1 answer
  • Sypherpk is good go sub 2 him
    6·2 answers
  • Who is tim berners-lee
    14·2 answers
  • Computer programming 5
    10·1 answer
  • How do you put text in MS publisher?<br><br> When do you use text wrapping?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!