using java language   Scanners are handy for reading input that is stored in a file. For this exercise, create a file called "numbers.txt" that contains the following data:         1.0   2.0  3.0  4.0         2.0   3.0  4.0  5.0         3.0   4.0  5.0  6.0  7.0         6.0   7.0  8.0  9.0 10.0 Read each line, convert the numbers in each line to doubles, and print the total for each row.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 11RQ
icon
Related questions
Question

using java language

 

Scanners are handy for reading input that is stored in a file. For this exercise, create a file called "numbers.txt" that contains the following data:

        1.0   2.0  3.0  4.0
        2.0   3.0  4.0  5.0

        3.0   4.0  5.0  6.0  7.0
        6.0   7.0  8.0  9.0 10.0


Read each line, convert the numbers in each line to doubles, and print the total for each row.

Expert Solution
Step 1

The below given Java program will obey the following rubrics:

  • Including necessary data packages.
  • In the main() method, creating a file instance.
  • Instantiating Scanner class.
  • While loop will read data from the file.
  • Reading data from the file and storing it in s string
  • Displaying string s, on the console.
  • Splitting the values of String and store them in the values array.
  • Creating a new array d of double types, the size of this array is the same as the values array.
  • for loop, will parse all the data to double and storing in the d array.
  • Another for loop, the statement is used for calculating the sum.
  • Finally displaying calculated sum on the console.
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT