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
artcher [175]
3 years ago
6

Define a function named LargestNumber that takes three integers as parameters and returns the largest integer. Define a second f

unction named SmallestNumber that takes three integers as parameters and returns the smallest integer. Then, write a main program that reads three integers as inputs, calls functions LargestNumber() and SmallestNumber() with the inputs as arguments, and outputs the largest and the smallest of the three input values. CORAL
Computers and Technology
1 answer:
marishachu [46]3 years ago
3 0

Answer:

Explanation:

The following code is written in Java and creates both of the requested methods. The methods compare the three inputs and goes saving the largest and smallest values in a separate variable which is returned at the end of the method. The main method asks the user for three inputs and calls both the LargestNumber and SmallestNumber methods. The output can be seen in the attached image below.

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter number 1: ");

       int num1 = in.nextInt();

       System.out.println("Enter number 2: ");

       int num2 = in.nextInt();

       System.out.println("Enter number 3: ");

       int num3 = in.nextInt();

       System.out.println("Largest Value: " + LargestNumber(num1, num2, num3));

       System.out.println("Smallest Value: " + SmallestNumber(num1, num2, num3));

   }

   public static int LargestNumber(int num1, int num2, int num3) {

       int max = num1;

       if (num2 > num1) {

           max = num2;

       }

       if (num3 > max) {

           max = num3;

       }

       return max;

   }

   public static int SmallestNumber(int num1, int num2, int num3) {

       int smallest = num1;

       if (num2 < num1) {

           smallest = num2;

       }

       if (num3 < smallest) {

           smallest = num3;

       }

       return smallest;

   }

}

You might be interested in
. ............... package is used by compiler itself. So it does not need to be imported for use.
Contact [7]

Answer: The compiler automatically imports the java.lang package.

Explanation:

Java packages are defined as a collection of classes, interfaces, and the like. Java programs utilize the components in the packages to implement their functionalities. Packages are either imported by the compiler or by the user through import keyword. The user can import any package using the import keyword. The import statements are always written at the beginning of the program.

<em>import java.math.* ;</em>

For example, the programmer writes the above statement that imports the java.math package into the java program.

Default packages are automatically imported by the compiler.

Default packages include java.lang packages. This default package is made up of all the classes and functions that are mandatory to any java program. Without java.lang package, the java program cannot be compiled and hence, becomes useless. The Java compiler adds the import statement for the default package, java.lang, at the beginning of the compilation. Hence, the statement

<em>import java.lang.*;</em>

does not needs to be written in the program.

The java.lang package consists of useful components which are required for various operations that can be done on the datatypes found in Java language. This package consists of classes and functions which relates to each data type and defines the functions which can be utilized to perform the operations allowed for the respective data types.

The java.lang package consists of Object, String, Math, System, Thread, Exception classes and wrapper classes like Integer, Double etc.. All the operations that can be implemented on the above-mentioned data types utilize the functions defined in their respective classes.

For example, printing on the console is done using System class.

<em>System.out.println();</em>

Also, all the operations done on strings use the methods such as append(), insert(), delete(), and replace(), etc, are pre-defined in the String class in the java.lang package.

Without java.lang package, any Java program cannot be useful.

6 0
4 years ago
Which if statement does not check for the condition "the month is between May and August and num_finals_left is zero?" Assume th
larisa [96]

Answer:

Option b  if month in ["May", "June", "July", "August"] and not num_finals:

Explanation:

The if statement in the option b doesn't meet the objective to check if num_finals is zero. It just use a not operator which is not relevant here.  The num_finals is an integer and therefore to check if num_finals is zero, the correct statement should be num_finals == 0  The "==" is an equality operator to check if a left value is equal to the right value. The rest of the three options are correct as they meet the checking requirements.

3 0
4 years ago
Which of the following is true of binary files?
alina1380 [7]
Try using socrative to answer your question it’s really good
3 0
3 years ago
Read 2 more answers
If you experience database corruption, what should you do before performing a restore operation
Vinvika [58]
<span>If we experience database corruption, one thing we should do before performing a restore operation</span><span> is to backup the transaction log tail.</span>
3 0
4 years ago
Which function does the Subtotal feature use?
Klio2033 [76]

max is the right answer because it give us subtotal

4 0
3 years ago
Other questions:
  • Presentation software allows business professionals to _____.
    14·2 answers
  • How can the storage model assist in the design of storage networks?
    12·1 answer
  • To find if the Library owns the item listed below using Quick SearchLinks to an external site., what would you type in the searc
    9·1 answer
  • True or false This html element puts the text in the centre of the webpage. "Something really cool "
    14·1 answer
  • Refer to the exhibit. A company is deploying an IPv6 addressing scheme for its network. The company design document indicates th
    11·1 answer
  • To configure a router/modem, what type of IP interface configuration should you apply to the computer you are using to access th
    10·1 answer
  • Use humorous and monster in a sentence.
    15·1 answer
  • Pleaseeeeeeeee I will give a brainliest
    7·1 answer
  • Which term accurately describes agile and devops
    5·1 answer
  • Why do we create user accounts to customize our preferences​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!