Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- import java.math.*;
- class Area {
- public static void main(String args[]) {
- int side, length, breath;
- Scanner s = new Scanner(System.in);
- System.out.println("enter the value of side");
- side = s.nextInt();
- System.out.println("enter the value of length");
- length = s.nextInt();
- System.out.println("enter the value of breath");
- breath = s.nextInt();
- RectArea r = new RectArea();
- TriArea t = new TriArea();
- }
- }
- class RectArea extends Area {
- RectArea() {
- int area1 = (length * breath);
- System.out.println("value of the rectangular area is:" + area1);
- }
- }
- class TriArea extends Area {
- TriArea() {
- float height = ((side / 2) * 1.732);
- float area2 = ((height * side) / 2);
- System.out.println("value of the triangle area is:" + area2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement