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
BeauBeau
You're doing better than you think!
Chat with Beau
SteveSteve
Knowledge is a journey, you know? We'll get there.
Chat with Steve

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