Answers for "Java program to find perimeter of square"

2

Java program to find perimeter of square

java program to calculate area of square
import java.util.Scanner;
public class FindAreaOfSquare
{
   public static void main(String[] args)
   {
      Scanner sc = new Scanner(System.in);
      System.out.println("Please enter side of square: ");
      double side = sc.nextDouble();
      // formula area of square = side * side
      double area = side * side;
      System.out.println("Area of square is: " + area);
      sc.close();
   }
}
Posted by: Guest on October-30-2020
2

Java program to find perimeter of square

import java.util.Scanner;
public class SquarePerimeter
{
   public static void main(String[] args)
   {
      int side, perimeter;
      Scanner sc = new Scanner(System.in);
      System.out.print("Please enter side length of square: ");
      side = sc.nextInt();
      perimeter = 4 * side;
      System.out.print("Perimeter of square is: " + perimeter);
      sc.close();
   }
}
Posted by: Guest on October-30-2020

Code answers related to "Java program to find perimeter of square"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language