Horje
sololearn java shapes coding project Code Example
sololearn java shapes coding project
import java.util.Scanner;

abstract class Shape {
    int width;
    abstract void area();
}

public class Square extends Shape{
    
    Square(int w){
        width = w;
    }
    public void area(){
            System.out.println(width * width);
    }
}

public class Circle extends Shape{

    Circle(int w){
        width = w;
    }
    public void area(){
            System.out.println(Math.PI * width*width);
    }
}

public class Program {
    public static void main(String[ ] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        Square a = new Square(x);
        Circle b = new Circle(y);
        a.area();
        b.area();
    }
}




Java

Related
how to implement linked list in java without using collection framework Code Example how to implement linked list in java without using collection framework Code Example
java code to check if string is alphanumeric Code Example java code to check if string is alphanumeric Code Example
android application manifest Code Example android application manifest Code Example
java kommentointi Code Example java kommentointi Code Example
android action key Code Example android action key Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8