I was trying to store Name and CGPA of student in a file, but it store only name can somebody help me? Here is my Code...
class Marks {
public static void main(String[] args) {
Here is the main method to calculate CGPA
    ArrayList arrayList = new ArrayList();
    Scanner ed = new Scanner(System.in);
    Scanner sc=new Scanner(System.in);
    System.out.println("Enter the name of Students");
    arrayList.add(sc.next());
    System.out.println("Enter number of subjects");
    int n=sc.nextInt();
    double[] marks=new double[n];
    System.out.println("Enter marks of Sub1\t sub2\t sub3\t sub4\t");
    for(int i=0;i<n;i++)
    {
        marks[i]=sc.nextInt();
    }
    double grade[]=new double[n];
    double cgpa,sum=0;
    for(int i=0;i<n;i++)
    {
        grade[i]=(marks[i]/10) ;
    }
    for(int i=0;i<n;i++)
    {
        sum+=grade[i];
    }
    cgpa=sum/n;
    System.out.println("cgpa="+cgpa);
    System.out.println("percentage from cgpa="+cgpa*9.5);
Here is code to write in a file
    try {
        FileWriter fileWriter = new FileWriter("Report.txt");
        Iterator iterator = arrayList.iterator();
        while (iterator.hasNext()){
            fileWriter.write(iterator.next()+"\n");
        }
        fileWriter.close();
    }catch (IOException e){
        System.out.println("!!!ERROR!!!");
    }
 }
}
 
     
    