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
Sharon is thinking about opening a bakery. She knows she wants to set her own hours, reduce her stress and make a profit. But sh
kondaur [170]
C would not be a beginner move.

hope it helps
6 0
3 years ago
Is the movie IT really that scary ? Rate between 1-10, 10 being I had nightmares
mezya [45]
5 I don’t think it’s good. I thought it was boring.
4 0
3 years ago
Ivan inputs a phone number into cell A2 of an Excel workbook. He formats the cell using a phone number format: (555) 987-6543. I
Temka [501]
The formula if he copies correctly if not plain numbers
8 0
3 years ago
Where might the Null Object pattern be useful?
Tanzania [10]

Answer:  Null Object pattern be useful when the absence of an object can be encapsulated by other alternatives which does not have any have any effect.

Explanation:

public interface Rectangle {

double area();

   double surfaceare();

   boolean isNull();

}

In the code above we have a function for null object. So in the absence of an object we have encapsulated with a method of null which does not do anything. It simplifies the use of dependencies that can be undefined.

In case of collaborator the NULL object pattern makes use of the existing collaboration instead of defining a new one.

It also enable to abstract the handling of null objects from the client so that internal details of the program are not know to outsiders.

5 0
3 years ago
Phases of systems development life cycle do developers identify the particular features nd functions of a new system
ki77a [65]

The phase where developers identify the particular features and functions of a new system is the requirement and analysis stage.

<h3>What is system development?</h3>

System development is the process of defining, designing, testing, and implementing a new software application or program.

System development has a life cycle. The primary stages are as follows;

  • Planning stage
  • Requirement and Analysis
  • Design
  • Development
  • Testing
  • Implementation.
  • Operation and maintenance.

Therefore, the phase where developers identify the particular features and functions of a new system is the requirement and analysis stage.

learn more on system development here: brainly.com/question/13042526

#SPJ12

7 0
2 years ago
Read 2 more answers
Other questions:
  • Dwight <br> d. eisenhower was impressed with germany's network of highways and how it __________.
    15·1 answer
  • 2.2-2 Consider sorting numbers stored in array by first finding the smallest element n A of and exchanging it with the element i
    11·1 answer
  • Creating a call conversion in Google Ads and adding a phone snippet to a web page allows advertisers to use a Google forwarding
    11·1 answer
  • Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 38 then the outpu
    11·1 answer
  • Files exist on ____ storage devices, such as hard disks, dvds, usb drives, and reels of magnetic tape.
    11·1 answer
  • Which of the following are incident priorities?
    9·1 answer
  • You want to use the randrange() method. Which line will allow you to enter the following code in IDLE?
    12·2 answers
  • Are there any Potential Dangers in Artificial Intelligence?
    11·2 answers
  • * what is an electronic mail ?
    13·1 answer
  • The capital letter Wis expressed as U+0057 in which system?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!