Daire.java

public class Daire extends Sekil {

private int yaricap;

public Daire(String isim, int yaricap) {
    super(isim);
    this.yaricap = yaricap;
}

@Override
void alanhesapla() {
    System.out.println(getIsim() + "alani " + yaricap * yaricap * Math.PI);
}
}

Kare.java

public class Kare extends Sekil{

private int kenar;

public Kare(String isim, int kenar) {
    super(isim);
    this.kenar = kenar;
}

@Override
void alanhesapla() {
    System.out.println(getIsim() + " alani " + kenar*kenar);
}

}

Ucgen.java

public class Ucgen extends Sekil {

private int a;
private int b;
private int c;

public Ucgen(String isim, int a, int b, int c) {
    super(isim);
    this.a = a;
    this.b = b;
    this.c = c;
}

@Override
void alanhesapla() {
    double u = (a + b + c)/2.0;
    double alan = Math.sqrt(u*(u-a)*(u-b)*(u-c));
    System.out.println(getIsim() + " alani " + alan);
}

}

Sekil.java

public abstract class Sekil {

private String isim;

public Sekil(String isim) {
    this.isim = isim;
}

abstract void alanhesapla();

public String getIsim() {
    return isim;
}

public void setIsim(String isim) {
    this.isim = isim;
}


}

Main.java

import java.util.Scanner;

public class Main {

public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String islemler = "Islemler: \n"
        + "1-Kare \n"
        + "2-Ucgen \n"
        + "3-Daire \n"
        + "q-Cikis";
    while (true) {
        System.out.println(islemler);
        System.out.println("Hangi seklin alanini hesaplamak istiyorsunuz : ");
        String sekilturu = scanner.nextLine();
        Sekil sekil = null;
        if (sekilturu.equals("q")) {
            System.out.println("Cikiliyor.");
            break;
        } else if (sekilturu.equals("1")) {
            System.out.println("Karenin kenari : ");
            int kenar = scanner.nextInt();
            scanner.nextLine();
            sekil = new Kare("Kare", kenar);
            sekil.alanhesapla();
        } else if (sekilturu.equals("2")) {
            System.out.println("a kenari : ");
            int kenar1 = scanner.nextInt();
            System.out.println("b kenari : ");
            int kenar2 = scanner.nextInt();
            System.out.println("c kenari : ");
            int kenar3 = scanner.nextInt();
            scanner.nextLine();
            sekil = new Ucgen("Ucgen", kenar1, kenar2, kenar3);
            sekil.alanhesapla();
        } else if (sekilturu.equals("3")) {
            System.out.println("Dairenin yaricapi : ");
            int kenar = scanner.nextInt();
            scanner.nextLine();
            sekil = new Daire("Daire", kenar);
            sekil.alanhesapla();
        } else {
        System.out.println("Hatali giris...");
        }
    }
}
}