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 = 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
The code youve provided reads integers from a text file Datatxt and calculates the average of these ... View full answer
Get step-by-step solutions from verified subject matter experts
