Define rectangle class and calculate area,perimeter in scala
Answers
Answered by
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
Math,
6 months ago
Business Studies,
1 year ago
Computer Science,
1 year ago
Math,
1 year ago
Chemistry,
1 year ago