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
sergeinik [125]
3 years ago
14

Write an algorithm to print the minimum and maximum of an integer array. Your need to pass the array as a parameter. Since we ca

nnot return two values (in this case, minimum and maximum), just print them inside the method. You are allowed to use only one loop. i.e. you are not allowed to traverse the array twice. Note: You can write a Java method instead of pseudo-code but pseudo-code is preferred. Following is a template to start your pseudo code. MinMax(A) min
Computers and Technology
1 answer:
sammy [17]3 years ago
4 0

Answer:

See explaination

Explanation:

MinMax.java

import java.util.*;

public class MinMax

{

static void MinMax(int[] arr)

{

int Min=arr[0]; // initializinf min and max with 1st value of array

int Max=arr[0];

for(int i=0;i<arr.length;i++) // iterating loop only once

{

if(arr[i]>Max) // checking max value

{

Max=arr[i];

}

if(arr[i]<Min) // checking min value

{

Min=arr[i];

}

}

System.out.println("Min Number is "+Min); //printing min value

System.out.println("Max Number is "+Max); //printing max value

}

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.print("Enter N value: "); // taking n value

int n=sc.nextInt();

int[] arr=new int[n];

System.out.println("Enter N elements:"); // taking n elements into array

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

{

arr[i]=sc.nextInt(); // each element into the array

}

MinMax(arr); // calling MinMax() method.

}

}

You might be interested in
A(n) _______ attack attempts to make a server or network unavailable to serve legitimate users by flooding it with attack packet
malfutka [58]

Answer:

DoS or Denial of Service

Explanation:

Have a nice day! :)

3 0
2 years ago
A sosit vara.copiii sunt veseli pentru ca au luat vacanta,mii de fluturi colorati zboara pe ceruri senine,soarele straluceste ve
hodyreva [135]
Acest lucru nu este calculator și tehnologie acest lucru arata ca acesta poate fi un poem pare rău, dar acest lucru trebuie postat in categoria engleză!! Mulțumesc

4 0
3 years ago
In which type of attack does the user respond to several external communication requests? Harry wants to watch a movie online by
Shkiper50 [21]

Answer:

They normaly do that to put a virus on your device And hack into your private info like passwords and credit cards and stuff like that

Explanation:

Always watch a movie leagly

3 0
3 years ago
Not everything is a success all of the time! So do you know which version of Windows was the least popular?
mario62 [17]

Answer:

windows xp

Explanation:

I think because it is not fast and don't play the games and programs which have higher requirements

7 0
3 years ago
Ning wants to gather data about humidity for a science project. Which of these are needed to gather data?
IgorLugansk [536]

Answer:

A -  information

Explanation:

in the question it says Ning wants to GATHER DATA for the project so, he need information.

IF im wrong, plz tell me and sry if i am

8 0
3 years ago
Read 2 more answers
Other questions:
  • To copy text in a Word document to an Excel spreadsheet, you should first format the text as a Word table or as text separated b
    11·2 answers
  • On an open book test, Anna was asked to predict how American laws may affect the Mexican way of life if the US Constitution was
    15·1 answer
  • A proprietary operating system designed for mobile devices, with associated libraries, user interface, frameworks and reference
    9·1 answer
  • Imagine the user types in a complete sentence, but we want to read only the first word and place it in the String variable word.
    11·1 answer
  • True or False (type the entire word)
    11·1 answer
  • ) Consider the array called myArray declared below that contains and negative integers. Write number of positive integers in the
    14·1 answer
  • Cassie is worried about credential management on a network where users often have over six passwords to remember. She’s curren
    13·1 answer
  • Write a java program that would request user name, id number, and state the time the user has reported at work.​
    12·1 answer
  • 6
    9·1 answer
  • True or false? To help improve SEO, your URL should match the title of your blog post, word for word.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!