Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Quadrilateral{
- int length, breadth;
- A(){
- length = 0;
- breadth = 0;
- }
- A(int side){
- length = side;
- breadth = side;
- }
- A(int length, int breadth){
- this.breadth = breadth;
- this.length = length;
- }
- int area(){
- return length*breadth;
- }
- }
- class FindArea{
- public static void main(String[] args){
- Scanner sc = new Scanner(System.in);
- System.out.print("1.Square 2.Rectangle: ");
- int choice = sc.nextInt();
- switch(choice){
- case 1: System.out.print("Enter the side: ");
- int side = sc.nextInt();
- System.out.println(new A(side).area());
- break;
- case 2: System.out.println("Enter the length & breadth:-");
- int length = sc.nextInt();
- int breadth = sc.nextInt();
- System.out.println(new A(length, breadth).area());
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement