📄 TxtOlustur.java .java dosyası

⬇️ İndir
import java.io.*; public class TxtOlustur { public static void main(String[] args) { String[] ogrenciIsimleri = {"Bekir", "Asim", "Ferhunde", "Filiz", "Güngör"}; int[] okulNumaralari = {123, 234, 345, 456, 567, 678, 789}; String[] dersIsimleri = {"Matematik", "Fen", "Tarih", "Ingilizce", "Resim"}; try { FileWriter writer = new FileWriter("src/data/ogrenci_bilgileri.txt"); for (int i = 0; i < 7; i++) { String studentName = ogrenciIsimleri[(int)(Math.random() * ogrenciIsimleri.length)]; int schoolNumber = okulNumaralari[(int)(Math.random() * okulNumaralari.length)]; int[] grades = new int[10]; for (int j = 0; j < 10; j++) { grades[j] = (int)(Math.random() * 100); } writer.write(studentName + "," + schoolNumber + ","); for (int j = 0; j < 5; j++) { writer.write(dersIsimleri[j] + "," + grades[j*2] + "," + grades[j*2+1] + ","); } writer.write("\n"); } writer.close(); System.out.println("Dosya başarıyla oluşturuldu!"); } catch (IOException e) { System.out.println("Dosya oluşturulamadı!"); e.printStackTrace(); } } }