Connect with one of the following accounts


Please wait while we redirect...

Views: 80   

Following program shows you how to calculate square area and circumference.
This program gets square length from user and calculates area and circumference and prints them using following formulas
Area = length X length
Circumference = 4 X length

import java.util.Scanner;

public class MathGeometry10 {

    public static void main(String[] args) {

        double squareLength;

        Scanner in = new Scanner(;

        System.out.println("Enter length of square:");
        squareLength = in.nextInt();

        double areaOfSquare = squareLength * squareLength;
        System.out.println("Area of square is: " + areaOfSquare);

        double circumferenceOfSquare = 4 * squareLength;
        System.out.println("Circumference of square is: " + circumferenceOfSquare);



Enter length of square:
Area of square is: 25.0
Circumference of square is: 20.0

On By

Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News