// Allison Obourn, CSE 142 // Displays average gas prices for the USA and Belgium calculated from // data from a file. 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 belgium = 0; double usa = 0; int count = 0; while(input.hasNext()) { belgium += input.nextDouble(); usa += input.nextDouble(); count++; input.next(); } System.out.println("Belgium average: " + belgium / count + " $/gal"); System.out.println("USA average: " + usa / count + " $/gal"); } }