Computer Science, asked by Ethan9375, 1 year ago

Define rectangle class and calculate area,perimeter in scala

Answers

Answered by gurukulamdivya
0

Answer:

import java.io.*;  

 

class Rectangle {  

 

   // Utility function  

   static int areaRectangle(int a, int b)  

   {  

      int area = a * b;  

      return area;  

   }  

 

   static int perimeterRectangle(int a, int b)  

   {  

      int perimeter = 2*(a + b);  

      return perimeter;  

   }  

     

   // Driver Function  

   public static void main (String[] args) {  

 

       int a = 5;  

       int b = 6;  

       System.out.println("Area = "+ areaRectangle(a, b));  

       System.out.println("Perimeter = "+ perimeterRectangle(a, b));  

 

   }  

}

Similar questions