Computer Science, asked by bidiptobose2187, 7 months ago

Write a program to accept length and breadth of a rectangle and print the area and perimeter. Also print the average of the area and the perimeter found.

Answers

Answered by monosijdas82pa9gm5
8

Answer:

/* Java Program Example - Calculate Area Perimeter of Rectangle */

 

import java.util.Scanner;

public class JavaProgram

{

   public static void main(String args[])

   {

       int len, bre, peri, area;

       Scanner scan = new Scanner(System.in);

 

       System.out.print("Enter Length and Breadth of Rectangle : ");

       len = scan.nextInt();

       bre = scan.nextInt();

 

       area = len*bre;

       peri = (2*len) + (2*bre);

 

       System.out.print("Area = " +area);

 

       System.out.print("\nPerimeter = " +peri);

   }

}

Explanation:

Answered by Equestriadash
24

I'm using Python to type out this code.

choice = "Yes"

while choice == "Yes":

   l = float(input("Enter the length of the rectangle: "))

   b = float(input("Enter the breadth of the rectangle: "))

   area = l*b

   perimeter = 2*(l + b)

   print(area, "is the area and", perimeter, "is the perimeter.")

   print()

   avg = (area + perimeter)/2

   print(avg, "is the average of the area and perimeter found.")

   print()

   choice = input("Would you like to go again? [Yes/No]: ")

Similar questions