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
vovikov84 [41]
3 years ago
9

Write a main program that prompts users for 5 integers. Use two separate functions to return (NOT print) the highest and lowest

value of the 5 integers. From main, display all five numbers entered and the results.
Computers and Technology
1 answer:
Soloha48 [4]3 years ago
6 0

Answer:

import java.util.Arrays;

import java.util.Scanner;

public class LatinHire {

   public static void main(String[] args) {

       Scanner in = new Scanner (System.in);

       System.out.println("Enter Five integers");

       int num1 = in.nextInt();

       int num2 = in.nextInt();

       int num3 = in.nextInt();

       int num4 = in.nextInt();

       int num5 = in.nextInt();

       int [] intArray = {num1,num2,num3,num4,num5};

       System.out.println(Arrays.toString(intArray));

       System.out.println("The Maximum is "+returnMax(intArray));

       System.out.println("The Minimum is "+returnMin(intArray));

   }

   public static int returnMax(int []array){

       int max = array[0];

       for(int i=0; i<array.length; i++){

           if(max<array[i]){

               max= array[i];

           }

       }

       return max;

   }

   public static int returnMin(int []array){

       int min = array[0];

       for(int i=0; i<array.length; i++){

           if(min>array[i]){

               min= array[i];

           }

       }

       return min;

   }

}

Explanation:

  1. This is implemented in Java Programming Language
  2. Two Methods are created returnMax(Returns the Maximum Value of the five numbers) and returnMin(Returns the minimum of the five numbers)
  3. In the Main method, the user is prompted to enter five numbers
  4. The five numbers are saved into an array of integers
  5. The returnMax and returnMin methods are called and passed the array as parameter.
  6. The entire array of numbers inputted by the user as well the Max and Min are printed

You might be interested in
Complete the program by writing and calling a function that converts a temperature from Celsius into Fahrenheit. Use the formula
Rina8888 [55]

Answer:

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

F = (C * (9 /5)) + 32

print(" {} in Fahrenheit is {} ". format(C, F))

Explanation:

The program takes an input from the user and converts the input to a fahrenheit.

4 0
3 years ago
Displays information a bout drivers, network connections, and other program-related details.
slava [35]

Answer:

library

Explanation:

hope you like it

6 0
3 years ago
To prepare a list of the ten largest cities in Asia, Luke should most likely use data to
kakasveta [241]
He should find answers about the population size hope this helps 
5 0
3 years ago
Read 2 more answers
What does the following code print?double[] myList = {1, 5, 5, 5, 5, 1};double max = myList[0];int indexOfMax = 0;for (int i = 1
Liula [17]

Answer:

This code will print: 4

Explanation:

Following is the step-by-step explanation for the given code:

  • Given is the array of data type double named myList, it has entries, 1, 5, 5, 5,5, 1:

                    double[] myList = {1, 5, 5, 5, 5, 1};

  • Now the first element of the array (1) with index 0 will be stored in the variable max (data type double).

                 double max = myList[0];  

  • A variable indexOfMax having datatype int will be initiated as 0.

                 int indexOfMax = 0;

  • Now for loop will be used to find the maximum number of the array. The variable i will be put as index for each element to compare with first element. If the checked element is greater than or equal to the integer in max, it will be replaced. So at the end the variable max will have value 5 that will be at index i = 4.

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

                            { if (myList[i] >= max)

                               { max = myList[i];

  • Now the variable i that is the index for max value will be stored in the variable indexOfMax (indexOfMax = 4).

                  indexOfMax = i; }}

  • At end the value stored in variable indexOfMax will be printed, so 4 will be printed as output.

              System.out.println(indexOfMax);

i hope it will help you!

7 0
3 years ago
You're working on a TV that has a hard coded list of channels (use an enum for this list) and you're asked to create a mechanism
ra1l [238]
Jsjsjsoos I jdkkskso I iDisks I iiddikdk I ididkkd
8 0
3 years ago
Other questions:
  • A Game Object must have a Transform<br><br> True<br><br> False
    5·1 answer
  • Summarize who you believe cyber criminals are, and why?
    8·1 answer
  • Consider the following C code fragment:
    10·1 answer
  • Write a Python program calculate summary statistics about a class assignment. First, prompt the user for the number scores to be
    6·1 answer
  • **NEED HELP??!! Computer Science Questions!! KNOWING GIMP!!!!
    7·1 answer
  • Write a SELECT statement that returns three columns: VendorName from Vendors table, DefaultAccount No from Vendors table, Accoun
    10·2 answers
  • High level language - An object oriented programming language​
    5·1 answer
  • Add the following method to the Point class: public double distance(Point other) Returns the distance between the current Point
    12·1 answer
  • Synthesize (15 points)
    13·1 answer
  • Describe the type of gameplay seen during early video games (ex. Spacewar!, Pong).
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!