Computer Science, asked by avi4653, 11 months ago

Write a program to with methods -

int peri_Square(int s) : to find perimeter of a square with given side.

int peri_Rect(int a, int b) : to find perimeter of a rectangle with given length and width.

Write a main method to invoke the following methods and pint the output.

Sample Input : Enter side of square in cms – 4

Sample Output : Perimeter of the square with side 4cm is 16cm.

Sample Input : Enter length of rectangle in cms – 6

Enter width of rectangle in cms – 3

Sample Output : Perimeter of the rectangle is 18cm.​

Answers

Answered by prashantrohilla32
2

Answer:

public class Main

{

 public static int peri_Square(int a)

  {  

     int sq_peri;

     sq_peri=4*a;

     return sq_peri;

   }

     

 public static int peri_Rect(int a,int b)

   {

     int rec_peri;

     rec_peri=2*(a+b);

     return rec_peri;

   }

   

  public static void main(String[] args) {

   

System.out.println("Perimeter of square = "+peri_Square(4)+ " cms");

System.out.println("Perimeter of rectangle= "+peri_Rect(6,3)+ " cms");

   

  }

}

Explanation:

Attachments:
Answered by Anonymous
0

18 cm....

f●llo ₩ me....

Similar questions