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
Leno4ka [110]
3 years ago
10

Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the t

hree values. If the input is 7 15 3, the output is: largest: 15 smallest: 3 Your program should define and call two functions: Function LargestNumber(integer num1, integer num2, integer num3) returns integer largestNum Function SmallestNumber(integer num1, integer num2, integer num3) returns integer smallestNum The function LargestNumber should return the largest number of the three input values. The function SmallestNumber should return the smallest number of the three input values.
Computers and Technology
1 answer:
arlik [135]3 years ago
8 0

Answer:

import java.util.*;

public class Main

{

public static void main(String[] args) {

    Scanner input = new Scanner(System.in);

    System.out.print("Enter the first number: ");

    int n1 = input.nextInt();

    System.out.print("Enter the second number: ");

    int n2 = input.nextInt();

    System.out.print("Enter the third number: ");

    int n3 = input.nextInt();

 System.out.println("largest: " + LargestNumber(n1, n2, n3));

 System.out.println("smallest: " + SmallestNumber(n1, n2, n3));

}

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

    int largestNum = 0;

    if(num1>=num2 && num1>=num3)

        largestNum = num1;

    else if(num2>=num1 && num2>=num3)

        largestNum = num2;

    else if(num3>=num1 && num3>=num2)

        largestNum = num3;

       

    return largestNum;

}

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

    int smallestNum = 0;

    if(num1<=num2 && num1<=num3)

        smallestNum = num1;

    else if(num2<=num1 && num2<=num3)

        smallestNum = num2;

    else if(num3<=num1 && num3<=num2)

        smallestNum = num3;

       

    return smallestNum;

}

}

Explanation:

Create function called LargestNumber that takes three parameters, num1, num2, num3. Find the largest number using if else structure among them and return it. For example, if num1 is both greater than or equal to num2 and num3, then it is the largest one.

Create function called SmallestNumber that takes three parameters, num1, num2, num3. Find the smallest number using if else structure among them and return it. For example, if num1 is both smaller than or equal to num2 and num3, then it is the smallest one.

Inside the main, ask the user for the inputs. Call the functions and print the largest and smallest.

You might be interested in
c++ Write a statement that increments (adds 1 to) one and only one of these five variables: reverseDrivers parkedDrivers slowDri
Mazyrski [523]

Answer:

The following statement are:

if(speed < 0) // if statement

{

reverseDrivers++; //if the speed is less than 0, then increment in "reverseDrivers"

}

else if(speed < 1) //else if statement

{

parkedDrivers++; //speed is less than 1, than increments in "parkedDrivers"

}

else if(speed < 40)

{

slowDrivers++; //speed is less then 40, than increment in "slowDriver"

}

else if(speed <= 65)

{

safeDrivers++; //speed is less than or equal to 40, then increment in "safeDriver"

}

else

{

speeders++; //else increment in speeders

}

Explanation:

From the following statement their are certain condition arises

If the speed is less than 0, then increments the “reverseDrivers” variable by 1.

If the speed is less than 1, then increments the “parkDriver” variable by 1.

If speed is less than 40, then increment in "slowDriver" variable by 1.

If speed is less than or equal to 40, then increment in "safeDriver" variable by 1.

Otherwise increment in "speeders"

7 0
3 years ago
All of the following are examples of extracurricular activities except:
mart [117]
A, because normally that would be a requirment
8 0
3 years ago
Read 2 more answers
Hey guys... so my dad reset my history on my laptop, and now when i try to login to discord it says "new login location detected
igor_vitrenko [27]

Answer:

do nothing it will happen itself

8 0
3 years ago
Read 2 more answers
You configured the IP address and DNS name of a new internal web server named WEB3. Your first test from a web browser on your w
bonufazy [111]

Answer:

I would reset the Domain Name System (DNS)

Explanation:

One factor that could lead to the "Site Cannot Be Reached" error is DNS "poisoning". Another is invalid DNS cache. Both can be caused by an attack on the system by people trying to spoof the system. Spoofing ensures that even when the right address is entered, it leads one to another web address.

One way to quickly reset the DNS is to run ipconfig /flushdns

This helps to clear the DNS cache.

Once the DNS cache has been successfully flushed, the system returns a confirmatory message that reads “flushed the DNS resolver cache”.

The systems administrator can now proceed to reconfigure the IP address(es)

Cheers

3 0
3 years ago
Program ___________________ are written explanations that are not part of the program logic but that serve as documentation for
Aleks04 [339]

Answer:

Program Comments

Explanation:

program comments are explanations. They are not executable code and the can actually appear anywhere in your code. Their main function is code documentation for the future. In Java programming language for example three types of comments is used. These are

// Single line comments  (This starts with two forward slashes

/* Multiple Line

comment

Style*/    

The third is the javadoc that gives a description of a function. I looks like the multiple line but is has two asterics

/** This is javadoc

comment

style*/

8 0
3 years ago
Other questions:
  • Casual or informal group meetings are common. Here youcasually chat over tea, meet after work, or get together for purelysocial
    5·1 answer
  • While researching ideas for cutting energy costs is his company. Hector watches an online video in which a business expert says,
    6·2 answers
  • Prompt the user to input an integer, a double, a character, and a string, storing each into separate variables. Then, output tho
    9·1 answer
  • What is an electronic tool that stores large amounts of data in one place in a systematic, logical way? A Database B Platform C
    5·1 answer
  • How can the font type of an existing style named No Spacing be changed?
    14·2 answers
  • This is the term for the manual process of editing strips of the film before digital editing was created. The term is still used
    9·1 answer
  • You are network administrator for an Active Directory forest with a single domain. Then network has three sites with one domain
    12·1 answer
  • Select the best answer from the drop-down menu.
    14·2 answers
  • Which method is useful for dimensionality reduction especially for small data-sets?
    15·1 answer
  • Becca is working on a program that will store data. The program will need quick access to data and data persistence is not impor
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!