viewing paste Unknown #21349 | Text

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
import java.util.*;
 
class Areas {
    int areaR(int l, int w){
        return (l*w);
    }
    double areaT(float b, float h){
        return(0.5*b*h);
    }
    double areaC(float r){
        return(3.14*r*r);
    }
}
 
class Area {
    public static void main(String args[]) {
        Areas a = new Areas();
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter Length and Width of Rectangle");
        int l = sc.nextInt(), w = sc.nextInt();
        System.out.println("Enter Base and Height of Triangle");
        float b = sc.nextFloat(), h = sc.nextFloat();
        System.out.println("Enter Radius of Circle");
        float r = sc.nextFloat();
        System.out.println("Area of Rectangle: "+ a.areaR(l,w));
        System.out.println("Area of Triangle: "+ a.areaT(b,h));
        System.out.println("Area of Circle: "+ a.areaC(r));
    }
}
Viewed 986 times, submitted by Guest.