Computer Science, asked by babyrizwana9, 7 months ago

Q14. Write a program that uses initialisation to calculate the area and perimeter of
rectangle.​

Answers

Answered by Anonymous
7

Answer:

Step by step descriptive logic to find perimeter and area of a rectangle.

  • Input length and width of rectangle from user. Store it in some variable say length and width.
  • Apply formula to calculate rectangle perimeter i.e.perimeter = 2 * (length + width).
  • Apply formula to calculate rectangle area i.e.area = length * width.
  • Finally, print the value of perimeter and area.
Answered by SƬᏗᏒᏇᏗƦƦᎥᎧƦ
21

/* Rectangle.java */

public class Rectangle

{

public static void main( String Args [ ] )

{

int length = 3 , width = 4 ;

int area ;

System.out.println ("Length is : " + length );

System.out.println ("Width is : " + width ) ;

System.out.println (" Area is : " ( length * width ) ) ;

System.out.println ("Perimeter is : " + ( 2 * ( length + width ) ) ) ;

}

}

Output

Length is : 3

Width is : 4

Area is : 12

Perimeter is : 14

hope it helps you

Similar questions