// // Review for Java // // Goal: read in data from a file and sum up them // // import java.util.Scanner; import java.text.DecimalFormat; public class SumUpData { public static void main(String[] args) { DecimalFormat f2 = new DecimalFormat("0.00"); Scanner input = new Scanner(System.in); int data; int sum = 0; int size = 0; double average; while(input.hasNext()) { data = input.nextInt(); // read data sum = sum + data; size ++; } average = (double)sum / size; System.out.println("Average = " + f2.format(average)); } }