Computer Science, asked by ron46, 1 year ago

Write a program in Java to Calculate the area and Perimeter of a Square ​

Answers

Answered by dipayanghosh185
15

Answer:

package org.learn;

import java.util.Scanner;

public class AreaAndPerimeterOfSquare {

public static void main(String[] args) {

 try (Scanner scanner = new Scanner(System.in)) {

  System.out.printf("1. Enter side of square : ");

  double side = scanner.nextDouble();  

   

  //Area of square is side * side

  double area = side * side;

  //Print area up to two precision

  System.out.printf("2. Area of square is : %4.2f",area);

 

  //Area of square is side * side

  double Perimeter = 4 * side;

  //Print area up to two precision

  System.out.printf("\n3. Perimeter of square is : %4.2f",Perimeter);

 }

}

}

HOPE YOU LIKE IT...

THEN PLEASE FOLLOW ME OR MAKE ME BRAINLIST ......

Explanation:

Answered by pragyakirti12345
1

Answer:

Explanation:

// Program to calculate the area and perimeter of a square

import java.util.Scanner;

public class CalculationsOfSquare {

public static void main(String[] args) {

try (Scanner scanner = new Scanner(System.in)) {

System.out.println(" Enter  the side of square : ");

double side = scanner.nextDouble();  

//Area of square is side * side

double area = side * side;

//Print area up to two precision

System.out.println("Area of square is : %4.2f",area);

//Perimeter of square = 4 * side

double Perimeter = 4 * side;

//Print area up to two precision

System.out.println("Perimeter of square is : %4.2f",Perimeter);

}

}

}

#SPJ3

Similar questions