Answers for "java program to calculate the area and the perimeter of a rectangle"

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
0

Write a java program to print the length and perimeter of a rectangle

import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
int length, breadth, peri, area;
Scanner scan = new Scanner(System.in);
System.out.print("Enter length and breadth of Rectangle ");
length = scan.nextInt();
breadth = scan.nextInt();
area = length*breadth;
peri = (2*length) + (2*breadth);
System.out.print("Area = " +area);
System.out.print("\nPerimeter = " +peri);
}
}
Posted by: Guest on July-04-2021

Code answers related to "java program to calculate the area and the perimeter of a rectangle"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language