answersLogoWhite

0


Best Answer

public int max(int x, int y, int z){ return Math.max(x,Math.max(y,z)); }

The method Math.max() only accepts 2 arguments, so you need to perform this method twice if you want to compare 3 numbers, as per the code above.

User Avatar

Wiki User

7y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

9y ago

public int max(int i1, int i2, int i3) {

return Math.max(i1, Math.max(i2, i3));

}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a method that takes 3 values as input parameters and returns the largest of three values?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the function that returns the largest value in a set of values?

MAX


What are the purpose of a method parameter?

Method Parameters or Arguments are values that are passed to methods to aid the method in carrying out its intended functionality. Ex: public int add() {} The above method is named "add" because it is supposed to add a few numeric values. But what will this method add? It needs input values that need to be added. Look at the below declaration public int add(int a, int b) {} This looks better because now we know that, this method is supposed to add the two numbers that are passed to it. Here "a" and "b" are the parameters to the method


Why method overloading is not possible by return type method?

A method can be used, and the return type discarded. For example, for a method that returns, say, an integer, instead of calling it like this: int x; x = MyMethod(1, 2); You can also call it like this: MyMethod(1, 2); That is, without using the return value. In such a case, if you were to have different methods with the same parameters but different return values, the compiler wouldn't know which version of the method to use.


How many arguments can be passed to an applet using PARAM tags Explain all the parameters?

two arguments can be passed to applet using param tags NAMES and VALUES <PARAM NAME ="name" VALUES = "values"> Parameters are passed to applets in NAME=VALUE pairs in <PARAM> tags between the opening and closing APPLET tags. Inside the applet, you read the values passed through the PARAM tags with the getParameter() method of the java.applet.Appletclass.


In java methods what are arguments?

Let's assume you have a method call, and a method, like this:// In the main program:int x = 5;myMethod(x, 10)...// Some lines later:void myMethod (int parameter1, int parameter2){// Do something here}The arguments - values 5 and 10 - are passed to the method, myMethod. This means a copy of these values is passed to the method, for its use. (Technically, the values are placed on the stack, where the other method accesses them.)The method will then have the values available. This allows for a method to be flexible, being able to processes different sets of data. For example, instead of writing a method to calculate the square root of 2, you write a method that calculates the square root of any number - passed as an argument.

Related questions

What is the function that returns the largest value in a set of values?

MAX


What are the purpose of a method parameter?

Method Parameters or Arguments are values that are passed to methods to aid the method in carrying out its intended functionality. Ex: public int add() {} The above method is named "add" because it is supposed to add a few numeric values. But what will this method add? It needs input values that need to be added. Look at the below declaration public int add(int a, int b) {} This looks better because now we know that, this method is supposed to add the two numbers that are passed to it. Here "a" and "b" are the parameters to the method


What is global parameters?

Some ADARUN parameters are global parameters; that is, they must have the same values for all nuclei in a cluster.


Why method overloading is not possible by return type method?

A method can be used, and the return type discarded. For example, for a method that returns, say, an integer, instead of calling it like this: int x; x = MyMethod(1, 2); You can also call it like this: MyMethod(1, 2); That is, without using the return value. In such a case, if you were to have different methods with the same parameters but different return values, the compiler wouldn't know which version of the method to use.


What is the difference between min and max function?

The MIN function returns the lowest value from a set of values. The MAX function returns the highest value from a set of values.=MIN(A2:A20)=MAX(A2:A20)The MIN function returns the lowest value from a set of values. The MAX function returns the highest value from a set of values.=MIN(A2:A20)=MAX(A2:A20)The MIN function returns the lowest value from a set of values. The MAX function returns the highest value from a set of values.=MIN(A2:A20)=MAX(A2:A20)The MIN function returns the lowest value from a set of values. The MAX function returns the highest value from a set of values.=MIN(A2:A20)=MAX(A2:A20)The MIN function returns the lowest value from a set of values. The MAX function returns the highest value from a set of values.=MIN(A2:A20)=MAX(A2:A20)The MIN function returns the lowest value from a set of values. The MAX function returns the highest value from a set of values.=MIN(A2:A20)=MAX(A2:A20)The MIN function returns the lowest value from a set of values. The MAX function returns the highest value from a set of values.=MIN(A2:A20)=MAX(A2:A20)The MIN function returns the lowest value from a set of values. The MAX function returns the highest value from a set of values.=MIN(A2:A20)=MAX(A2:A20)The MIN function returns the lowest value from a set of values. The MAX function returns the highest value from a set of values.=MIN(A2:A20)=MAX(A2:A20)The MIN function returns the lowest value from a set of values. The MAX function returns the highest value from a set of values.=MIN(A2:A20)=MAX(A2:A20)The MIN function returns the lowest value from a set of values. The MAX function returns the highest value from a set of values.=MIN(A2:A20)=MAX(A2:A20)


An argument takes a value or values and performs an operation?

In programming, an argument takes a value or vales and performs an operation is called a function or method. If a method does not return a value, it is described as 'void'.


How many arguments can be passed to an applet using PARAM tags Explain all the parameters?

two arguments can be passed to applet using param tags NAMES and VALUES <PARAM NAME ="name" VALUES = "values"> Parameters are passed to applets in NAME=VALUE pairs in <PARAM> tags between the opening and closing APPLET tags. Inside the applet, you read the values passed through the PARAM tags with the getParameter() method of the java.applet.Appletclass.


Constructor functions can receive values?

Of course constructors can receive values as parameters, there are not any restriction about it. An constructor is a special method executed when we instanted an object (we create an object with the 'new' operator) and as a method it can receive any kind of parameter: public MyConstructor (int value1, int value2){ //do something with the values } public MyConstructor (MyObject obj){ //do something with the object } The above code shows two constructors (in java code) with different type and number of parameters. The only restrictions are that they use the name of the class and have no return type.


A function takes in values of variable called inputs and gives back values of the variable called outputs?

No. A function takes in values of no, one, or more input variables, and returns no or one result. It cannot return more than one result. Do not confuse this with returning multiple results using call by reference parameters - this is not the same thing.


In java methods what are arguments?

Let's assume you have a method call, and a method, like this:// In the main program:int x = 5;myMethod(x, 10)...// Some lines later:void myMethod (int parameter1, int parameter2){// Do something here}The arguments - values 5 and 10 - are passed to the method, myMethod. This means a copy of these values is passed to the method, for its use. (Technically, the values are placed on the stack, where the other method accesses them.)The method will then have the values available. This allows for a method to be flexible, being able to processes different sets of data. For example, instead of writing a method to calculate the square root of 2, you write a method that calculates the square root of any number - passed as an argument.


What is the parameter for 3G drive test?

sir please tell me the parameters of 3g drive test....and its exact values in drive parameters...


Why the functions of java is called methods?

because it is capable of taking parameters, passing or returning values as in c++. it has it's own identity as return type, and signature of the method body. It can also be overloaded as well.