Define a class TwoD which contains the following methods:
i) void rect(int L, int B) - Calculate the area of the rectangle
ii) void circ(int R) - Calculate the area of circle.
Invoke both the methods from main function and display the area of both rectangle and
circle.
Answers
Answered by
0
public class TwoD {
void rect(int L, int B) {
System.out.println("Area of Rectangle - " + (L * B));
}
void circ(int R) {
System.out.println("Area of Rectangle - " + (Math.PI * R * R));
}
public static void main(String[ ] args) {
TwoD area = new TwoD( );
area.rect(12, 13);
area.circ(12);
}
}
Similar questions