Swapping two numbers by multiplication and division

 Swapping two numbers by multiplication and division



Problem Description


Java Program to Swap two numbers by using division and multiplication.


Logic Test Case 1


Input (stdin)

3 2


Expected Output


2 3

Logic Test Case 2


Input (stdin)

20 45


Expected Output


45 20



Code Area

import java.io.*;

import java.util.Scanner;

public class TestClass {

public static void main(String[] args) 

     {

       int num1,num2;

       Scanner s=new Scanner(System.in);

       num1=s.nextInt();

       num2=s.nextInt();

       num1=num1*num2;

       num2=num1/num2;

       num1=num1/num2;

       System.out.print("" + num1 + " " +num2);

   }

}



Post a Comment

0 Comments