answersLogoWhite

0

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;

}

}

User Avatar

Wiki User

14y ago

Still curious? Ask our experts.

Chat with our AI personalities

ReneRene
Change my mind. I dare you.
Chat with Rene
BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake
RafaRafa
There's no fun in playing it safe. Why not try something a little unhinged?
Chat with Rafa

Add your answer:

Earn +20 pts
Q: Write algorithm of a largest number and smallest number among three numbers?
Write your answer...
Submit
Still have questions?
magnify glass
imp