This is the current code of the trouble area:
// Prompt for the input file name
Scanner console = new Scanner(System.in);
System.out.print("Input file: ");
String inputFile = console.next();
// Create variables
String line = null ;
File input = new File(inputFile);
BufferedReader in = new BufferedReader(new FileReader(input));
double sum = 0;
while ((line = in.readLine())!= null)
{
String [] plist = line.split("[\\s}]");
for (int i=0; i < plist.length; i++)
{
sum =+ Double.parseDouble(plist [2]);
}
}
System.out.println("Total value of properties listed: " + sum);
in.close();
This reads the bufferend input file, one line at a time, then should split it into various elements (4 columns of data), then should sum the total of column 3 (plist [2]). Instead my sum equals the value of the item in the last row.
Any insight greatly appreciated!
Thank,


Sign In
Create Account

Back to top









