Advertisement
CR7CR7

swap

Jun 23rd, 2022
1,135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. import java.util.Scanner;
  2.  import java.text.DecimalFormat;
  3.  
  4. public class ExchangeIfGreater {
  5.     public static void main(String[] args) {
  6.         Scanner in = new Scanner(System.in);
  7. double x = in.nextDouble();
  8. double y = in.nextDouble();
  9. DecimalFormat df = new DecimalFormat("0.###");
  10.  
  11. if (x > -100 && x < 100 && y > -100 && y < 100) {
  12.     if (x > y) {
  13.         System.out.println(df.format(y) + " " +df.format(x));
  14.     } else {
  15.         System.out.println(df.format(x) + " " +df.format(y));
  16.     }
  17.     }
  18.   }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement