我正在制作一个程序,该程序在指定数量的课程中创建成绩日志并将此数据写入文本文件。它写了日期、班级名称、成绩(或者至少应该写)和结束语。由于某种原因我无法弄清楚,我的程序只打印出日期和班级名称。有任何想法吗?
这是代码:
BufferedWriter data = null; //Writes Output
try {
File log = new File ("Grade.txt"); //Name of File
FileWriter fileWriter = new FileWriter (log, true); //Appends File
data = new BufferedWriter (fileWriter); //Creates BufferedWriter
Date date = new Date (); //Sets Date
//Code here makes an array of class names
System.out.print ("Enter Assignment Name: ");
title = reader.nextLine ();
data.write (title);
data.newLine (); //Blank Line
reader.nextLine (); //Consume Input
System.out.print ("Enter Points Possible: ");
temp = reader.nextInt();
if (temp < 0){
throw new ArithmeticException ("");
}else{
poss += temp;
data.write(poss);
}//Close If
System.out.print ("Enter Points Earned");
temp = reader.nextInt();
if (temp < 0){
throw new ArithmeticException ("");
}else{
earn += temp;
data.write(earn);
}//Close If