Computer Science, asked by ushshssjjsjs301, 1 month ago

Write a program in java to find and display the area and perimeter of a square, where side of

a square is 10.​

Answers

Answered by anindyaadhikari13
1

Solution:

The given problem is solved in Java.

public class Main{

   public static void main(String args[]){

       int side, perimeter, area;

       side = 10;

       perimeter = 4 * side;

       area = side * side;

       System.out.println("Side of the square = " + side + " unit.");

       System.out.println("Perimeter of the square = " + perimeter + " unit.");

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

   }

}

Logic:

To display the perimeter, area of the square,

(1) Initialise side = 10 unit.

(2) Initialise perimeter = 4 x side.

(3) Initialise area = side x side.

(4) Now display the perimeter and area of the square using print() statement.

See attachment for output.

Attachments:
Similar questions