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
When is padding required for a structure type variable? Group of answer choices When the structure contains a word-type variable
yarga [219]

Answer:When the structure contains a word-type variable, such as integer, float, and pointer, and the total number of bytes is not a multiple of four ---A

Explanation:Structure padding is the assigning of members of a structure to appear at the correct byte boundary. To achieve this, padding is added by a complier so that structure members can appear in thier correct location, taking into consideration also the size of the structure which must be arranged orderly to the memory so that the padding can reoccur at the end of the structure.

For example--

For a structured type variable, padding is required when the structure contains a word-type variable, such as integer, float, and pointer, and the total number of bytes ie depending on the type of byte fed into the memory for the specific purpose.

6 0
3 years ago
You designed a program to find the midpoint of two points. Which step below corresponds to finding the average of the x-coordina
MrRa [10]

Answer:

Perform any needed calculations or data manipulations.

Explanation:

just did the test

hope it helps

8 0
3 years ago
Write a program to accept two numbers<br>in two lines and find Square root of Squares<br>of thion​
lawyer [7]

Answer: Here you go, change it however you like :)

Explanation:

num1 = int(input("Enter a number: "))

num2 = int(input("Enter a number: "))

print(f"square root of num1: {num1**0.5}")

print(f"square root of num2: {num2**0.5}")

3 0
3 years ago
How long does it take a letter to arrive?
viktelen [127]
Depends on who yourmail carrier is traffic weather how much mail they have
5 0
3 years ago
What is meant by editing a document​
Doss [256]

Answer: “Editing” in general means fixing problems in a written document so that it has no mistakes and is easy to read

Explanation: Yeah

5 0
3 years ago
Read 2 more answers
Other questions:
  • Recursion is memory-intensive because ________. Select one: a. it requires large data values b. it must occur numerous times bef
    11·1 answer
  • Design a 4-to-16 line Decoder by using the two 3*8 decoder-line decoders. The 3-to-8 line decoders have an enable input ( '1' =e
    13·1 answer
  • Diagnosing is solving the problem, and trouble shooting is figuring out what the problem is.
    15·1 answer
  • Write a main method that prompts the user for an integer between 1 &amp; 20 (inclusive). If the user enters an invalid number, p
    8·1 answer
  • What feature is available to add a suggestion in the margin of someone else's document?
    7·1 answer
  • Print 'userNum1 is negative" if userNum1 is less than 0. End with newline Convert userNum2 to 0 if userNum2 is greater than 9. O
    8·1 answer
  • I thought the answer was senior manager see on google it says
    8·1 answer
  • Send the memes whoever is the best will get that crown thing lol
    10·2 answers
  • You want a class to have access to members ofanother class in the same package. Which is themost restrictive access that accompl
    11·1 answer
  • To reposition the legend to the left-hand side of a chart, click the _________ button, point to legend, click the right arrow ic
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!