Number Swapper
Single File Programming Question
Problem Statement
You have been tasked with creating a class, NumberSwapper, that allows for swapping two integer numbers. However, there's a special condition: if the two numbers are identical, there's no need to swap them, and this condition should be indicated.
Implement a Class NumberSwapper and a constructor public NumberSwapper(int num1, int num2) to swap two numbers.
Input:
format :The first line of the input contains an integer num1 representing the first number.
The second line contains an integer num2 representing the second number.
Output:
format :The output is displayed in the following format:
If num1 is equal to num2, the program prints: "Numbers are identical and need not be swapped"
If num1 is not equal to num2, the program prints: "Numbers after swapping: Number1={newNum1}, Number2={newNum2}"
Refer to the sample output for formatting specifications.
Code constraints : The given test cases fall under the following constraints:
-100 ≤ num1 ≤ 1000
-100 ≤ num2 ≤ 1000
Sample test cases :
Input 1:
10
10
Output 1 :
Numbers are identical and need not be swapped
Input 2 :
5
7
Output 2 :
Numbers after swapping: Number1=7, Number2=5
Input 3 :
0
15
Output 3 :
Numbers after swapping: Number1=15, Number2=0