Computer Science, asked by dastitli700, 2 months ago

write the programs in java using Given value:
3. The length and breadth of the rectangle is 5cm and 8cm , calculate and print the area and perimeter​

Answers

Answered by anindyaadhikari13
4

Solution:

The given c‎ode is written in Java.

public class Rectangle {

   public static void main(String[] args){

      int length=8,breadth=5,area,perimeter;

      area=length*breadth;

      perimeter=2*(length+breadth);

      System.out.println("Area: "+area);

      System.out.println("Perimeter: "+perimeter);

   }

}

Logic:

  • Logic is very simple, declare and initialise length and breadth and calculate the area and perimeter using formula.

See the attachment for output.

Attachments:
Answered by kamalrajatjoshi94
2

Answer:

Program:-

public class Main

{

public static void main(String args[])

{

int l=5,b=8,ar=0,pr=0;

ar=l*b;

pr=2*(l+b);

System.out.println("The area of rectangle="+ar);

System.out.println("The perimeter of rectangle="+pr);

}

}

Attachments:
Similar questions