import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class OgrenciBilgileriOkuma {

    public static void main(String[] args) {
        File file = new File("src/data/ogrenci_bilgileri.txt");

        try {
            Scanner scanner = new Scanner(file);
            System.out.println("Ogrenci adi\tOkul No.\tDers Ismi.\t1. Not.\t\t2. Not.\t\t%40.\t\t%60.\t\tSonuc");
            while (scanner.hasNextLine()) {
                String line = scanner.nextLine();
                String[] data = line.split(",");
                String ogrenciAdi = data[0];
                String okulNo = data[1];

                // DÜZELTME: Her ders için 3'erli gruplar halinde ilerle
                for (int i = 2; i < data.length - 1; i += 3) {
                    String dersIsmi = data[i];                    // Matematik
                    int not1 = Integer.parseInt(data[i + 1]);     // 2
                    int not2 = Integer.parseInt(data[i + 2]);     // 71
                    
                    // DÜZELTME: Doğru hesaplama
                    int not40 = (int) (not1 * 0.4);
                    int not60 = (int) (not2 * 0.6);
                    int notOrtalamasi = not40 + not60;
                    
                    System.out.printf("%-15s\t%-10s\t%-15s\t%-10d\t%-10d\t%-10d\t%-10d\t%-10d\n", 
                                     ogrenciAdi, okulNo, dersIsmi, not1, not2, not40, not60, notOrtalamasi);
                }
                System.out.println(); // Öğrenciler arası boşluk
            }
            scanner.close();
        } catch (FileNotFoundException e) {
            System.out.println("Dosya bulunamadi: " + e.getMessage());
        }
    }
}