Write a program that calculates the area and perimeter of an rectangle but, to perform this program, multiple inheritance is used. Test Case 1 Input (stdin) 5.1 2.3 Expected Output 11.73 14.80 Test Case 2 Input (stdin) 1.5 2.5 Expected Output 3.75 8.00
import java.io.*;
import java.util.Scanner;
public class TestClass {
public static void main(String[] args) {
double a,b,d,p;
Scanner sc = new Scanner(System.in);
a = sc.nextDouble();
b = sc.nextDouble();
p=a*b;
System.out.printf("%.2f",p);
d=2*(a+b);
System.out.printf("\n%.2f",d);
}
}