Write a program in java to accept the side of a square and calculate the area of the square
Answers
Answer:
/* Java Program Example - Calculate Area Perimeter of Rectangle */
import java.util.Scanner;
public class JavaProgram
{
public static void main(String args[])
{
int len, bre, peri, area;
Scanner scan = new Scanner(System.in);
System.out.print("Enter Length and Breadth of Rectangle : ");
len = scan.nextInt();
bre = scan.nextInt();
area = len*bre;
peri = (2*len) + (2*bre);
System.out.print("Area = " +area);
System.out.print("\nPerimeter = " +peri);
}
}
import java.util.*;
public class Area
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
float s,a;
System.out.println("Enter the side of the square"+s);
s= in.nextFloat();
a=Math.pow(s,2);
System.out.println("Display the area of the square"+a);
}
}