Header Ad

Java swing program to calculate square of a number

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 square of a number


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

Java swing program to calculate square of a number



Post a Comment

0 Comments