Java swing program to calculate square of a number YASH PAL, 31 July 2024 In this tutorial, we are going to write a Java swing program to calculate the square of a number in Java Programming with practical program code and step-by-step full complete explanation. Java swing program to calculate the square of a number. import java.awt.*; import javax.swing.*; public class InputOutput { public static void main(String arr[]) { String input=JOptionPane.showInputDialog("Enter a number"); int number=Integer.parseInt(input); int square=number*number; System.out.println("square = "+square); JOptionPane.showMessageDialog(null,"Square: " +square); System.exit(0); } } Output coding problems java