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
Gnom [1K]
3 years ago
6

How to write a program in java that finds the max number of an array of integers?

Computers and Technology
1 answer:
Anit [1.1K]3 years ago
7 0

Answer:

The following steps describes how to write a Java program that finds the maximum of an array of integers

STEP 1: Create the array

STEP 2: Intialize the array by assigning integers values of have the user enter the elements of the array using the Scanner class.

STEP 3: Create a temp variable and call it maxInt assign this variable to the element at index 0 of the array

STEP 4: Using a for loop Statement, iterate over every element of the array and check if they are greater than the maxInt variable which is at index 0.

STEP 5: Reassign the maxInt to a new element when ever a greater integer is found

STEP 6. Return or Printout the value of maxInt

The method below written in java shows all the steps listed above to find the max integer in an integer array

Explanation:

   public static int getMax(int[] arr){

       int maxInt = arr[0];

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

           if(arr[i] > maxInt){

               maxInt = arr[i];

           }

       }

       return maxInt;

   }

You might be interested in
Localize the software problem and describe it<br>​
sweet [91]

Answer:

Do you have any idea how to get the best and most importantly I

5 0
3 years ago
Assume that you have an ArrayList variable named a containing 4 elements, and an object named element that is the correct type t
jonny [76]

Answer:

Option (4) is the correct answer.

Explanation:

In Java programming language ,array collection starts from 0 index location and ends in a size-1 index location. So to access the last elements the user needs to use a[Size-1] statement. so to modify the value of the last location of the array the user needs to use "a[size-1]= element;".

But when the user wants to add some new value to the end of the array list collection then he needs to use the statement--

a.add(element); //where add is a function, element is a value and a is a array list object.

Another option is invalid because--

  • Option 1 is not the correct because "a[3]=element;" modify the value of the 3rd element of the array.
  • Option 2 gives a compile-time error because add functions bracts are not closed.
  • Option 3 gives the error because a[4] gives the location of the 5th element of the array but the above question says that a is defined with 4 elements.
7 0
3 years ago
Intranets:
SOVA2 [1]

Answer:

A, C, D and E

Explanation:

An intranet is synonymous to a private LAN or WAN network but in contrast to the extranet or internet. Resources are retrieved and/ or shared within devices in the private network. It uses the internet protocol suite model of networking for communication, but also uses private IP addresses, which are not routable on the internet.

The communication between devices can be a peer to peer connection or client-server connection, using the mainframe computer technologies as the dedicated servers of the network.

7 0
4 years ago
Name the reactants in the equation P+O​
zmey [24]
Reactants are the factors that yield the subdivision of a molecule. Products are the result of this division. In other words, reactants are left of the equation and products are on the right. P+O are reactants, but the product is not shown.
3 0
3 years ago
In what year was the first world-wide web software created by tim berners-lee?
Elena L [17]
1989 <span>A graduate of Oxford University, Tim Berners-Lee invented the Web while at CERN, the European Particle Physics Laboratory, in </span>1989<span>. He wrote the first web client and server in </span>1990<span>.</span>
6 0
3 years ago
Other questions:
  • Which option will you use to expose your presentation to the audience?
    8·2 answers
  • Technologies that function within the established system are called
    12·1 answer
  • The data manipulation language (DML) of SQL contains SELECT, INSERT, DELETE, and UPDATE statements, whereas the data definition
    12·1 answer
  • As a culture chnages so does its language<br><br> A.true <br> B.false
    5·1 answer
  • Which function returns a valid value without any arguments?
    14·2 answers
  • What memory stores instructions that tell the computer how to start up?
    10·1 answer
  • A key requirement for the process of testing hypotheses in the scientific method is Group of answer choices experimenter bias. c
    9·1 answer
  • (Bible)<br> Sin may be an inward thought or an outward act. True False
    11·2 answers
  • What was your first experience with listening to kpop?
    8·2 answers
  • look for ten websites and classify them as static or dynamic what makes each websites static or dynamic?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!