I am very new to java so please ignore my obvious errors. I have an txt files whose format is as following:
Student Name,Mathmatics_Marks,Physics_Marks,Chemistry_Marks,Biology_Marks
A,10,20,30,40
B,15,15,48,69
C,45,48,48,79
D,48,15,12,55
Desired Output:
I need to do the following output format from the above txt files:
Student Name (Appended with "Student:" prefix)
Pass/Fail (Appended with "Exam Status:" prefix)
Average_Marks (Appended with "Average_Marks:" prefix)
Maximum_Marks(Appended with "Maximum_Marks:" prefix)
Minimum_Marks(Appended with "Minimum_Marks:" prefix)
For example:
Student: A
Exam Status: Pass
Average_Marks:25
Maximum_Marks:40
Minimum_Marks:10
<<so on for other students>>
...........................
...........................
...........................
...........................
Logics/Algo for Desired Output:
1) If (Mathmatics_Marks+Physics_Marks+Chemistry_Marks,Biology_Marks)=>100 then Pass else Fail
2) Find out the average marks of student.
3) Write Maximum marks
4) Write Minimum marks
My Approach : 1- I am able to load data to ArrayList and Print data from txt file using following code but unable to achieve the desired output:
public static void main(String[] args)
{
//Input file path
String fileToParse = "C:\\Users\\DELL-PC\\Desktop\\Analysis.txt";
BufferedReader fileReader = null;
//Delimiter Declaration
final String DELIMITER = ",";
try
{
List<String> Student_log= new ArrayList<String>();
String line = "";
//Create the file reader
fileReader = new BufferedReader(new FileReader(fileToParse));
//Reading the file line by line
while ((line = fileReader.readLine()) != null)
{
//Get all tokens available in line
String[] tokens = line.split(DELIMITER);
for(String token : tokens)
{
//Print all tokens
/// Array Initialization Part
System.out.println(token);
Student_log.add(token);
}
}
}
catch (Exception e) {
e.printStackTrace();
}
finally
{
try {
fileReader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Please help me in my code.