Hi, I was wondering anyone one can help me please?
I am trying to write a program that read from a csv file called matches.csv.
A single football match can end with a win or a draw: in first case the winner team get 3 points and the loser none, in the second case of draw each of the two teams get 1 point.
For example, the first line of the file matches.txt is as follow:
In the file it contains the following data.
17/08/2013 Arsenal Aston Villa 1 3
24/08/2013 Aston Villa Liverpool 0 1
This means that a match has been played on the 17/08/2013 where Arsenal scored 1 goal while Aston Villa 3 goals: thus Arsenal got 0 points while Aston Villa 3 points.
How can I structure my output to make it make it read
Position Team Played Points
1 Aston Villa 2 3
2 Liverpool 1 3
3 Arsenal 1 0
import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Teams { public static void main(String[] args) { String fileName = "matches.csv"; File file = new File(fileName); try { Scanner inputStream = new Scanner(file); while (inputStream.hasNext()) { String data = inputStream.next(); System.out.println(data); } } catch(FileNotFoundException e) { e.printStackTrace(); } } }