answersLogoWhite

0


Best Answer

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

13y ago
This answer is:
User Avatar

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
Related questions

What is largest and smallest numbers that round off to 10000?

The smallest number is 5000 while largest number is 14999.


How do you write program to read a set of real numbers and find the range is given by the difference between largest and smallest number?

Use the following algorithm (written in pseudocode). Let largest be the lowest possible real number. Let smallest be the greatest possible real number. Repeat while there is input... { Read real number r from input. If r is greater than largest then let largest be r. If r is less than smallest then let smallest be r. } End repeat. Let range be largest minus smallest. Output range.


How do you work out the range in numbers?

Subtract the smallest number from the largest number.


What is the range of the consecutive odd numbers from 7 through to 35?

The range of a set of numbers is the range between the largest and the smallest number. This is basically the largest number in the sequence subtract the smallest number in the sequence. In this case, the smallest number is 7 and the largest number is 35. This makes the range 28.


What is the smallest and largest prime numbers with in 30?

The smallest prime number between 0 and 30 is 2, and the largest is 29.


What is the largest and smallest palindromic numbers?

I guess that the smallest would be zero, if you don't consider negative numbers. There is no largest palindromic number - you can make them as large as you like.


What is found when the smallest number is subtrated from the largest number in a set of numbers?

the range


What are the largest and smallest numbers rounded to the nearest thousand for 30000?

The smallest number would be 29500. The largest number would be 31499.


The smallest and the largest whole numbers that round to 300?

The largest whole number is 3499


How to find the range of numbers?

Subtract the smallest number from the largest number and you will get the distance from the smallest number to the largest number. That is the range. Ex: {-2 -4 -6 3 6 7 12} Smallest number is -6, largest number is 12. 12- (-6) = 12 + 6 = 18. The distance from the smallest number to the largest is 16


What is the largest number you can make from the digits in your phone number?

get the numbers and order them from biggest to smallest.


The smallest and the largest whole numbers that round off to 7000?

smallest possible whole number is 6500