Computer Science, asked by adfrt, 10 months ago

Write a program in java to accept the side of a square and calculate the area of the square

Answers

Answered by mustafa3952
2

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);

}

}

Answered by Anonymous
2

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);

}

}

Similar questions