Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*4.Write a program that finds the smallest of three numbers.*/
- /*Tests
- 5 2 2 0 -2.5 -5 -1.1 -0.5 -0.1
- ans: 2 -5 -1.1 */
- import java.util.Scanner;
- public class TheSmallestOf3Numbers {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- double a,b,c;
- System.out.println("Enter 3 numbers");
- System.out.println("Enter q to Quit");
- while(true){
- try {
- a = input.nextDouble();
- b = input.nextDouble();
- c = input.nextDouble();
- } catch (Exception e) {
- System.out.println("Bye!");
- break;
- }
- if (Math.min(a, b)<c) {
- System.out.println(Math.min(a, b));
- }
- else {
- System.out.println(c);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement