Computer Science, asked by compstudy, 7 months ago

write a java program using function argument to inpit three unequal numbers.display the greatest number among them​

Answers

Answered by ankita184132
1

Answer:

Java program to find the largest of three numbers, if the numbers are unequal, then "numbers are not distinct" is printed. Comparison operator '>' is used to compare two numbers. To find the largest number out of given numbers you can also use an array.

Answered by sanjanasrushti63
2

Answer:

Find Largest Among three numbers using if..else statement

public class Largest {

public static void main(String[] args) {

double n1 = -4.5, n2 = 3.9, n3 = 2.5;

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

System.out.println(n1 + " is the largest number.");

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

System.out.println(n2 + " is the largest number.");

else

System.out.println(n3 + " is the largest number.");

}

}

Output

3.9 is the largest number.

In the above program, three numbers -4.5, 3.9 and 2.5 are stored in variables n1, n2 and n3 respectively.

Then, to find the largest, the following conditions are checked using if else statements

If n1 is greater or equals to both n2 and n3, n1 is the greatest.

If n2 is greater or equals to both n1 and n3, n2 is the greatest.

Else, n3 is the greatest.

Hope it helps you lot . Please like and mark me as brainlist .

Thank you

Similar questions