5. JAVA Program to find Area and Perimeter of a Square.
How does this program work?
- In this programme you will learn about how to calculate Area and Perimeter of a Square.
- This programme requires the user input to nter the Length of the Square side.
- This programme perform mathematical calculation and display the result using JAVA.
Here is the code
//Area and Perimeter of a square
import java.util.Scanner;public class Main
{
public static void main(String args[])
{
int a,b,c;
System.out.println("Enter side of a square :");
Scanner obj=new Scanner(System.in);
a=obj.nextInt();
//Area of square is side * side
b=a*a;//Area of perimeter is 4 *side
c=4*a;System.out.println("Area of the square is " +b );
System.out.println("Perimeter of the square is "+c );
}
}