Question: Given the code below, public static void main(String[] args) throws FileNotFoundException File inputFile = new File(Data.txt); Scanner in= new Scanner(inputFile); int sum = 0;

Given the code below, public static void main(String[] args) throws FileNotFoundException File inputFile =

Given the code below, public static void main(String[] args) throws FileNotFoundException File inputFile = new File("Data.txt"); Scanner in= new Scanner(inputFile); int sum = 0; int count = 0; while (hasNextInt()) { sum+= in.nextInt(); count++; in.close(); System.out.println(sum / count); Considering Data.txt contains-3 1234 What would be the output?

Step by Step Solution

3.43 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The code youve provided reads integers from a text file Datatxt and calculates the average of these ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!