import java.io.*;
import java.util.*;
public class TextFile
{
public static void main(String[] args) throws FileNotFoundException, IOException
{
PrintWriter myWriter = new PrintWriter(args[0]);
ArrayList<TextFile> myNums = new ArrayList<TextFile>();
int max = Integer.MIN_VALUE;
int min = Integer.MAX_VALUE;
double sum = 0;
double average;
for(int i = 1; i < args.length; i++)
{
FileReader myReader = new FileReader(args[i]);
Scanner intScan = new Scanner(myReader);
while (intScan.hasNextLine())
{
String textLine = intScan.nextLine();
myWriter.println(textLine);
}
myReader.close();
}
for(int i = 0; i < args.length; i++)
{
sum = sum + intScan[i];
average = sum / args.length;
if(myNums[i] > max)
{
max = intScan[i];
}
if(myNums[i] < min)
{
min = intScan[i];
}
}
System.out.println("The number of entries in the file is: " + args.length);
System.out.println("The sum is: " + sum);
System.out.println("The average is: " + average);
System.out.println("The largest number is: " + max);
System.out.println("The largest number is: " + min);
myWriter.close();
}
}
}
我正在尝试编写一个程序,我从我正在使用的类文件夹中的文件中提取成绩,并创建一个数组列表,用于计算条目数,给出条目总和,平均值,最大值和最小值。我做错了什么?