Answers for "print the area and perimeter of a rectangle and square - constructer java source code"

1

Java program to find perimeter of a rectangle

import java.util.Scanner;
public class PerimeterOfRectangleDemo
{    
   public static void main(String []args)
   {
      float length, width, perimeter;
      Scanner sc = new Scanner(System.in);
      System.out.print("Please enter length of rectangle: ");
      length = sc.nextFloat();
      System.out.print("Please enter width of rectangle: ");
      width  = sc.nextFloat();
      perimeter = 2 * (length + width);
      System.out.println("Perimeter of rectangle: " + perimeter);
      sc.close();
   }          
}
Posted by: Guest on February-09-2021

Code answers related to "print the area and perimeter of a rectangle and square - constructer java source code"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language