write a program in java to input two numbers. Display the numbers after swapping them by using a third variable. Sample input a=95, b=45. Sample output a=45, b=95
Answers
Answered by
2
Answer:
import java.util.Scanner;
public class KboatNumberSwap
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.println("Enter two unequal numbers");
System.out.print("Enter first number: ");
int a = in.nextInt();
System.out.print("Enter second number: ");
int b = in.nextInt();
a = a + b;
b = a - b;
a = a - b;
System.out.println("a = " + a + " b = " + b);
I hope it works I'm not that good in computer science
Similar questions