// Tyler Rigsby, CSE 142 // Scans a file with gas prices of Belgium and USA, and reports // the average of each. import java.io.*; import java.util.*; public class GasPrices { public static void main(String[] args) throws FileNotFoundException { Scanner input = new Scanner(new File("gasprices.txt")); double belgiumPrices = 0; double usaPrices = 0; int count = 0; while (input.hasNext()) { belgiumPrices += input.nextDouble(); usaPrices += input.nextDouble(); input.next(); // ignore the date count++; } System.out.println("Average Belgium price: " + belgiumPrices / count); System.out.println("Average US price: " + usaPrices / count); } }