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
Which pair of devices have the same input motion and different outputs?
allochka39001 [22]

Answer:

nutcracker and can opener

Explanation:

5 0
2 years ago
What is the best method to avoid getting spyware on a machine
monitta

Answer: The best method to avoid getting spyware on a user machine is to download software only from trusted websites. And depending on the machine it might say that "This download you are about to install might have spyware or malware and it might infect your laptop" "Do you wish to continue?"

3 0
2 years ago
What technology has a function of using trusted third-party protocols to issue credentials that are accepted as an authoritative
jarptica [38.1K]

Answer: PKI certificates

Explanation: PKI is known as the public key infrastructure which is commonly used for the encryption of the data and also for the data signing. They have the ability to assign the keys pair.

PKI certificates are in the form of strings of alpha-numeric running for a mathematical functions. They use the third party protocols for the execution and they are widely accepted by the authoritative identity.

5 0
2 years ago
Encryption that uses 16-character keys is known as ____. strong 128-bit encryption strong 256-bit encryption military-strength 5
allsm [11]

Answer: Strong 128-bit encryption.

Explanation: An individual character corresponds to 8 bits . So if there are 16 characters then,

16\times8=128 bits keys

This makes the 128 bit key encryption the strongest amongst all other options.It is strongest because it is almost impossible to decode the 128-character key  by any method e.g.-brute-force method.

Other options are incorrect because the characters given by the other bits are as follows:  {\frac{256}{8}=32 characters

                         {\frac{512}{8}=64 characters

                         {\frac{512}{8}=128 characters  

Thus, the strongest character key is of 128 bits. for cipher.

3 0
2 years ago
A datagram network allows routers to drop packets whenever they need to. The probability of a router discarding a packetis p. Co
tresset_1 [31]

Answer:

a.) k² - 3k + 3

b.) 1/(1 - k)²

c.) k^{2}  - 3k + 3 * \frac{1}{(1 - k)^{2} }\\\\= \frac{k^{2} - 3k + 3 }{(1-k)^{2} }

Explanation:

a.) A packet can make 1,2 or 3 hops

probability of 1 hop = k  ...(1)

probability of 2 hops = k(1-k)  ...(2)

probability of 3 hops = (1-k)²...(3)

Average number of probabilities = (1 x prob. of 1 hop) + (2 x prob. of 2 hops) + (3 x prob. of 3 hops)

                                                       = (1 × k) + (2 × k × (1 - k)) + (3 × (1-k)²)

                                                       = k + 2k - 2k² + 3(1 + k² - 2k)

∴mean number of hops                = k² - 3k + 3

b.) from (a) above, the mean number of hops when transmitting a packet is k² - 3k + 3

if k = 0 then number of hops is 3

if k = 1 then number of hops is (1 - 3 + 3) = 1

multiple transmissions can be needed if K is between 0 and 1

The probability of successful transmissions through the entire path is (1 - k)²

for one transmission, the probility of success is (1 - k)²

for two transmissions, the probility of success is 2(1 - k)²(1 - (1-k)²)

for three transmissions, the probility of success is 3(1 - k)²(1 - (1-k)²)² and so on

∴ for transmitting a single packet, it makes:

     ∞                             n-1

T = ∑ n(1 - k)²(1 - (1 - k)²)

    n-1

   = 1/(1 - k)²

c.) Mean number of required packet = ( mean number of hops when transmitting a packet × mean number of transmissions by a packet)

from (a) above, mean number of hops when transmitting a packet =  k² - 3k + 3

from (b) above, mean number of transmissions by a packet = 1/(1 - k)²

substituting: mean number of required packet =  k^{2}  - 3k + 3 * \frac{1}{(1 - k)^{2} }\\\\= \frac{k^{2} - 3k + 3 }{(1-k)^{2} }

6 0
3 years ago
Other questions:
  • You notice that lately your computer has been running slow. When you open up your web browser, you get endless pop-up ads to the
    8·1 answer
  • Which of the following will most likely result in a decrease in population?
    11·2 answers
  • If a speed mismatch was configured between two Cisco routers' Ethernet interfaces, what would the status of this interface be?
    12·1 answer
  • When subjects are given two drinks but not told what they are drinking in order to get accurate results on which is the better t
    6·1 answer
  • Leah wants to add an image to her updated presentation, so she wants to access the Help interface. What should
    11·2 answers
  • The linear programming ingredient or blending problem model allows one to include not only the cost of the resource, but also th
    14·1 answer
  • Technician A says that as volume decreases, pressure increases. Technician B says that as temperature increases, pressure decrea
    15·2 answers
  • Ling has configured a delegate for her calendar and would like to ensure that the delegate is aware of their permissions. Which
    13·2 answers
  • Describe an example of a very poorly implemented database that you've encountered (or read about) that illustrates the potential
    12·1 answer
  • True or False? Security code is almost always open source!<br> True<br> False
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!