Question: Hi! I'm stuck with this step with getting sum. Should I need another println to do this in the while ? Here is Numbers.txt. download
Hi! I'm stuck with this step with getting sum. Should I need another println to do this in the while ?


Here is Numbers.txt.

download the data file numbers.txt (This is the same file you downloaded during the class). Process entire data from the file (Read data from the file), and calculate the sum of all numbers in the file. Your program should display a sample output as follows: It should work no matter how many values are in the file.)) Sample output: number - 308.2 number = 14.9 number = 7.4 number - 2.8 number = 3.9 number = 4.7 number = -15.4 number = 2.8 Sum = 329.3 import java.util.*; import java.io*; public class quizic { public static void main(String [] args ) { try { Scanner input = new Scanner ( new File( " numbers. txt")); while (input.hasNext()){ double n = input.next(); System.out.println(" number = "+ double n ) } } catch ( FileNotFoundException e){ System.out.println(e); } } } 308.2 14.9 7.4 2.8 3.9 4.7 2.8 -15.4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
