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
An Internet service provider that wants to influence consumers to immediately switch to its service would most likely utilize __
frutty [35]

Answer: Direct competitive

Explanation:

 The direct competitive situation occur when the two and more than two business in the market offering the similar type of services and the products so it automatically increase the level of competition in the market.

According to the question, the internet service is one of the most efficient tool for influence the customers or consumers about their products in the market and when the services are get switched then it utilize the direct competitive in the market.

Therefore, direct competitive is the correct option.

6 0
3 years ago
Jaboooo helloooo are u there
Fed [463]
?????????????????????
8 0
3 years ago
Read 2 more answers
How do i answer a qestion on brainly
viva [34]

Answer:

Click on an answer, then click "Add Answer +(?)"

Explanation:

This way you'll be able to add a question to any brainly question that you are able to add a question to. Such as this one. You will receive half the points that the person asking the question assigned to the question, with the minimum being 10 points. After this you will receive those points and be able to write a response much like this one allowing you and 1 other person to answer the same question and received thanks and or brainliest by which the user asking the question can give out to the person who they believe gave the best answer.

Hope this helps! <3

5 0
2 years ago
Plz help!!!!!!!!!!!!!!!!111
Y_Kistochka [10]

This question stuns me. Not sure which answer it is, but my best choice right now is probably the one you have selected in the image. A line graph would show the rate of plant growth over the course of a certain amount of days, resulting in which had the highest rates within that period. Might be wrong, but I hope you do well.

4 0
3 years ago
Increasing your margins will increase the amount of space you have to type text on your document. Please select the best answer
Ksenya-84 [330]

It is false because if the margins, the space on the side of a paper, gets bigger, that means there is more emptiness and less space for text.

4 0
3 years ago
Other questions:
  • Maggie is preparing a business report. Which types of keys will she use to type out words and numbers?
    6·2 answers
  • The concept of vertical farming allows agriculture to occur when there is not enough___Available .
    13·1 answer
  • Changing the position of the wing will
    9·1 answer
  • Identify the data set level of measurement for the following: individual tax filing status (single, head of household, widowed,
    8·1 answer
  • Use of multimedia in business sector...​?
    5·1 answer
  • Define the following term. data, database, DBMS, database system, data- base catalog, program-data independence, user wen', DBA,
    12·1 answer
  • ​Client/server computing is​ a: A. network that connects sensors to desktop computers. B. distributed computing model where clie
    12·1 answer
  • WILL UPVOTE ALL
    10·1 answer
  • Which of the examples is part of client-side code?
    12·1 answer
  • how does a demilitarized zone (dmz) work. A.By preventing a private network from sending malicious traffic to external networks
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!