➽ Program:-

import java.util.*;

class Main

{

   public static void main(String args[])

   {

      float num1, num2, temp;

      Scanner sc = new Scanner(System.in);

     

      System.out.print("Enter the First Number: ");

      num1 = sc.nextFloat();

      System.out.print("Enter the Second Number: ");

      num2 = sc.nextFloat();

     

      temp = num1;

      num1 = num2;

      num2 = temp;

     

      System.out.println("After swapping, First Number = " + num1);

      System.out.println("After swapping, Second Number = " + num2);

   }

➽ Output:-

Enter the First Number: 7.8
Enter the Second Number: 12.6
After swapping, First Number = 12.6
After swapping, Second Number = 7.8