Computer Applications
Write a program in Java to find the maximum of three numbers using Math.max() method.
Java
Java Math Lib Methods
37 Likes
Answer
import java.util.Scanner;
public class KboatGreatestNumber
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter First Number: ");
int a = in.nextInt();
System.out.print("Enter Second Number: ");
int b = in.nextInt();
System.out.print("Enter Third Number: ");
int c = in.nextInt();
int g = Math.max(a, b);
g = Math.max(g, c);
System.out.println("Greatest Number = " + g);
}
}
Output
![BlueJ output of Write a program in Java to find the maximum of three numbers using Math.max() method. BlueJ output of Write a program in Java to find the maximum of three numbers using Math.max() method.](https://cdn1.knowledgeboat.com/img/lgx10/c7-math-methods-greatest-number-java-program.jpg)
Answered By
16 Likes
Related Questions
Write a program to print:
i. x to the power y
ii. the square root of y
The values of x and y are 81 and 3, respectively.
Write valid statements for the following in Java:
i. Print the rounded off value of 14.49
ii. Print the absolute value of -0.09
iii. Print the largest of -67 and -50
iv. Print the smallest of -56 and -57.4
v. Print a random integer between 25 and 35
vi. Print 47.5 raised to the power 6.3
vii. Print minimum of -4, -7
Write the Java expression for the following:
Write a program to compute and display the value of expression:
where, the values of x, y and z are entered by the user.