Nackey

swao two variables

Jul 13th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class TrainingCodes2 {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int a = Integer.parseInt(scanner.nextLine());
  10.         int b = Integer.parseInt(scanner.nextLine());
  11.         int tmp = a;
  12.         if (a > b){
  13.             System.out.println(a = b);
  14.             System.out.println(b = tmp);
  15.         }else{
  16.             System.out.println("error");
  17.         }
  18.  
  19.  
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment