Write a Java method to find the smallest number among three numbers.
Solution
Q.1 Write a Java method to find the smallest number among three numbers.
Solution :-
import java.util.*;
class findsmall
{
public static double smallest(double x , double y , double z)
{
return Math.min(Math.min(x,y),z);
}
}
class Main1
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int x,y,z;
System.out.println(“Enter the First number :- “);
x = in.nextInt();
System.out.println(“Enter the Second number :- “);
y = in.nextInt();
System.out.println(“Enter the Third number :- “);
z = in.nextInt();
findsmall s1 = new findsmall();
double m1 = s1.smallest(x,y,z);
System.out.println(“The Smallest number is :- “+m1);
}
}
Fun & Easy to follow
Works on all devices
Your own Pace
Super Affordable
Popular Videos
Play Video
UX for Teams
Learn the basics and a bit beyond to improve your backend dev skills.
Chris Matthews
Designer
Play Video
SEO & Instagram
Learn the basics and a bit beyond to improve your backend dev skills.
Chris Matthews
Designer