Nesne Tabanlı Programlama (Güz-2016) Hafta-11
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 30 31 |
public abstract class ogrenci{ String[] harfler={"AA","BA","BB","CB","CC","DC","DD","FD"}; int[] sinirlar={90,80,70,60,50,40,35,30}; abstract int ortalamahesap(); /*int ortalamahesap() { return (int) (vizenot*0.4+finalnot*0.6 + 0.5); }*/ void harfhesapla() { int ortalama = ortalamahesap(); for(int i =0;i<harfler.length;i++) { if(ortalama>=sinirlar[i]) { System.out.println(ortalama+" ortalama icin harf: "+harfler[i]); return; } } System.out.println(ortalama+" ortalama icin harf: FF"); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
public class calistir extends ogrenci { public calistir() { harfhesapla(); } int ortalamahesap() { // hesaplama algoritmasi return 70; } public static void main(String[] asdad) { new calistir(); } } |