public class FindLeastAndGreatest
{
public static void main(String[] args)
{
// number can't be equal with each other
int a = 7;
int b = 7;
int c = 6;
System.out.println(least(a,b,c));
System.out.println(greatest(a,b,c));
}
public static int least(int a, int b, int c)
{
int least = 0;
if(a < b && a < c)
{
least = a;
}
else if(b < a && b < c)
{
least = b;
}
else { least = c;}
return least;
}
public static int greatest(int a, int b, int c)
{
int greatest = 0;
if(a > b && a > c)
{
greatest = a;
}
else if(b > a && b > c)
{
greatest = b;
}
else { greatest = c;}
return greatest;
}
}
Chat with our AI personalities
Subtract the smallest number from the largest number.
The smallest prime number between 0 and 30 is 2, and the largest is 29.
The largest whole number is 3499
Arrange the numbers from smallest to largest and find the middle number.
The smallest two digit number is 00 (a number used as a wire gauge) and the largest is 99, so the difference between the largest and smallest 2-digits numbers is 99 (99 - 00)