Advertisement
Guest User

Problem 4. The Smallest of 3 Numbers

a guest
May 15th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class TheSmallestO3Numbers {
  5.  
  6. public static void main(String[] args) {
  7. Scanner input = new Scanner(System.in);
  8. //Numbers
  9. System.out.print("Enter 3 numbers:");
  10. float a = input.nextFloat();
  11. float b = input.nextFloat();
  12. float c = input.nextFloat();
  13.  
  14. float min=a;
  15. if (b<min) {
  16. min=b;
  17. }
  18. if (c<min) {
  19. min=c;
  20. }
  21. //Replace floating point zeroes and print
  22. System.out.printf(Float.toString(min).replaceAll("\\.?0*$", ""));
  23. }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement