Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Write a program that finds the smallest of three numbers.
- import java.util.Locale;
- import java.util.Scanner;
- public class _04_TheSmallestOf3Numbers {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Locale.setDefault(Locale.ROOT);
- Scanner scan = new Scanner(System.in);
- System.out.print("Enter 3 Real numbers: ");
- double numA = scan.nextDouble();
- double numB = scan.nextDouble();
- double numC = scan.nextDouble();
- double smallest = numA;
- if (numB <= numA && numB <= numC) {
- smallest = numB;
- } else if (numC <= numA && numC <= numB) {
- smallest = numC;
- }
- System.out.println("The Smallest of these 3 numbers is: " + smallest);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement