Write a function named minMax() that accepts three integers arguments from the keyboard and finds the smallest and largest integers. Include the function minMax() in a working program. Make sure your function is called from main().Test the function by passing various combinations of three integers to it.

Answers

Answer 1
Answer:

Answer:

public class Main

{

public static void main(String[] args) {

 minMax(1, 2, 3);

 minMax(100, 25, 33);

 minMax(11, 222, 37);

}

public static void minMax(int n1, int n2, int n3){

    int max, min;

    if(n1 >= n2 && n1 >= n3){

        max = n1;

    }

    else if(n2 >= n1 && n2 >= n3){

        max = n2;

    }

    else{

        max = n3;

    }

   

    if(n1 <= n2 && n1 <= n3){

        min = n1;

    }

    else if(n2 <= n1 && n2 <= n3){

        min = n2;

    }

    else{

        min = n3;

    }

    System.out.println("The max is " + max + "\nThe min is " + min);    

}

}

Explanation:

*The code is in Java.

Create a function named minMax() that takes three integers, n1, n2 and n3

Inside the function:

Declare the min and max

Check if n1 is greater than or equal to n2 and n3. If it is set it as max. If not, check if n2 is greater than or equal to n1 and n3. If it is set it as max. Otherwise, set n3 as max

Check if n1 is smaller than or equal to n2 and n3. If it is set it as min. If not, check if n2 is smaller than or equal to n1 and n3. If it is set it as min. Otherwise, set n3 as min

Print the max and min

Inside the main:

Call the minMax() with different combinations


Related Questions

Susan is taking a French class in college and has been asked to create a publication for her class. What feature can sheuse to help her develop her publication in French?ResearchGrammarLanguageSpell Check
A common measure of transmission for digital data is the number of bits transmitted per second. Generally, transmission is accomplished in packets consisting of a start bit, a byte (8 bits) of information, and a stop bit. Using these facts, answer the following:a. Compute the time required to transmit an image of 1200x800 pixels with 8 bits for gray of each pixel using a 50 M bits/sec. modem?b.What would the time be at 3 M bits/sec, a representative of download speed of a DSL connection?(c) Repeat a and b when the image is RGB colored with 8 bits for each primary color. f 20 colored frames per second
Which vendor did IBM select to create the operating system for the IBM PC?
Consider the following definition of a recursive method. public static int mystery(int[] list, int first, int last) { if (first == last) return list[first]; else return list[first] + mystery(list, first + 1, last); } Given the declaration int[] alpha = {1, 4, 5, 8, 9}; What is the output of the following statement? System.out.println(mystery(alpha, 0, 4)); a. 1 b. 18 c. 27 d. 32
The scope of a variable declared inside of a function is:a) Local - within that functionb) Within that file onlyc) global

Give an example of a function from N to N that is:______.a) one-to-one but not onto
b) onto but not one-to-one
c) neither one-to-one nor onto

Answers

Answer:

Let f be a function

a) f(n) = n²

b) f(n) = n/2

c) f(n) = 0

Explanation:

a) f(n) = n²

This function is one-to-one function because the square of two different or distinct natural numbers cannot be equal.

Let a and b are two elements both belong to N i.e. a ∈ N and b ∈ N. Then:

                                f(a) = f(b) ⇒ a² = b² ⇒ a = b

The function f(n)= n² is not an onto function because not every natural number is a square of a natural number. This means that there is no other natural number that can be squared to result in that natural number.  For example 2 is a natural numbers but not a perfect square and also 24 is a natural number but not a perfect square.

b) f(n) = n/2

The above function example is an onto function because every natural number, lets say n is a natural number that belongs to N, is the image of 2n. For example:

                                f(2n) = [2n/2] = n

The above function is not one-to-one function because there are certain different natural numbers that have the same value or image. For example:

When the value of n=1, then    

                                   n/2 = [1/2] = [0.5] = 1

When the value of n=2 then

                                    n/2 = [2/2] = [1] = 1

c) f(n) = 0

The above function is neither one-to-one nor onto. In order to depict that a function is not one-to-one there should be two elements in N having same image and the above example is not one to one because every integer has the same image.  The above function example is also not an onto function because every positive integer is not an image of any natural number.

On React1) Create counter and an increment button, default value of the counter would be 1, clicking on increment button adds 5 to the counter. The max value of the counter would be 20, after reaching this value , counter would not increment. Add a reset button which would set the counter value to 1.
[8:53 PM]
2) Create a button with label “true” , clicking on the button toggle the value from “true” => “false” and “false” => “true”.(edited)

techsith (patel) — 03/03/2021
3) Create a counter and a button. clicking on the button increments the counter by one. double clicking on the button resets the counter to 0

Answers

Answer:too many words ahhh

Explanation:

(assuming jsx)

function Buttons (props) {

return(

{props.counterValue}

counter

increment

reset

);

}

var counterValue = 1;

function addup(a){

if(counterValue + a <= 20){

counterValue += a;

} else if (counterValue + a > 20){

//do nothing

}

ReactDOM.render(

 ,

 document.getElementById('root')

);

}

function reset() {

counterValue = 1;

ReactDOM.render(

 ,

 document.getElementById('root')

);

}

An objective function in linearprogramming is a(n):decisionvariable.
environmentvariable.
resultvariable.
independentvariable.
constant.

Answers

Answer: An objective function in linear programming is a decision variable.

Explanation: An objective function is a function which has the target towards the model whether it should be maximized or minimized according to the relation between the  variables present in the function. There are set of variables which are responsible for the controlling of objective function that is known as decision variables.

Suppose an array with six rows and eight columns is stored in row major order starting at address 20 (base 10). If each entry in the array requires only one memory cell, what is the address of the entry in the third row and fourth column?

Answers

Answer:

39

Explanation:

Since each of the address occupies only 1 memory cell and the 2-D array is row-major 2-D array.So the elements will be filled row wise.First the first row will be fully filled after that second row and so on.Since we want the address of the element at third row and fourth column.

we can generalize this :

address of the element at ith row and jth column=s + ( c * ( i - 1 ) + ( j - 1 ) ).

s=Starting address.

c=Number of columns in the 2-D array.

address=20+(8*(3-1)+(4-1))

=20+(8*2+3)

=20+16+3

=39

Or you can make a matrix of six rows and eight columns and put first cell with 20.Start filling the elements row wise one by one and look what is the count of 3rd row and 4th column.

CHALLENGE 7.1.1: Initialize a list. ACTIVITY Initialize the list short.names with strings 'Gus', Bob, and 'Ann'. Sample output for the given program Gus Bob Ann 1 short_names- Your solution goes here 2 # print names 4 print(short_names[0]) 5 print(short names [11) 6 print(short_names[2])

Answers

Answer:

short_names = ["Gus", "Bob", "Ann"]

print(short_names[0])

print(short_names[1])

print(short_names[2])

Explanation:

There are some typos in your code. In addition to the missing part of the code, I corrected the typos.

First of all, initialize the list called short_names. The list starts with "[" and ends with "]". Between those, there are must be the names (Since each name is a string, they must be written between "" and there must be a semicolon between each name)

Then, you can print each name by writing the name of the list and the index of the names between brackets (Index implies the position of the element and it starts with 0)

To return the value of the cell D8, the formula should be OFFSETA1=________.

Answers

Answer:

The formula is =OFFSET( A1, 7,3,1,1 )

Explanation:

Microsoft excel is a statistical and analytical tool for data management and analysis. Its working environment is called a worksheet. The worksheets are made up of rows and columns also known as records and fields respectively.

Functions like OFFSET in excel is used to return a cell or group of cells. It gets the position to turn by start getting a starting port, then the number of records below it and the fields after, then the length and width of cells to return.

syntax:   =OFFSET( "starting cell", "number of rows below", "number of columns after", "height of cells to return", "width of cells to return" )