Java Program to find Area of Square

In this article, you will see the logical program to find the area of a Square using java.

The Area of the square = side x side

For Example, a=4
Area => 4*4 => 16

Below is the java program to find the area of a square:

package com.javacodepoint.basics;

import java.util.Scanner;

public class AreaOfSquare {

	public static void main(String[] args) {

		// declare required variables
		double side, area;

		// create scanner object to read user inputs
		Scanner sc = new Scanner(System.in);

		// read one side of square
		System.out.print("Enter one side of square: ");
		side = sc.nextDouble();

		area = side * side;

		System.out.println("Area of the square :: " + area);

	}

}

OUTPUT:

Enter one side of square: 6
Area of the square :: 36.0

Java logical programs list


Java Basic Programs

Java Programs based on the Collection Framework

Leave a Reply

Your email address will not be published. Required fields are marked *