Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A Java program that reads the file input.txt and calculates and prints the average of all integer numbers in this file. SAMPLE OUTPUT: throws FileNotFoundException

A Java program that reads the file "input.txt" and calculates and prints the average of all integer numbers in this file. 

SAMPLE OUTPUT:

throws  FileNotFoundExceptiontry/catch

OUTPUT SAMPLE #1 for input.txt: 1 2 3 4 5 6 x x x 8 12 x x 34 x x 10 20
Number # 1 is: 1
Number # 2 is: 2
Number # 3 is: 3
Number # 4 is: 4
Number # 5 is: 5
Number # 6 is: 6
Number # 7 is: 8
Number # 8 is: 12
Number # 9 is: 34
Number # 10 is: 10
Number # 11 is: 20
The average of 11 numbers/file = 9.55

OUTPUT SAMPLE #2 for input.txt: xxxxx x x x x xx x x x x x
The file doesn't contain any integers. Exit program!

OUTPUT SAMPLE #1 for input.txt: 1 2 3 4 5 6 x x x 8 12 x x 34 x x 10 20
Please input the name of the file to be opened: input.tx
--- File Not Found! ---

OUTPUT SAMPLE #2 for input.txt: 1 2 3 4 5 6 x x x 8 12 x x 34 x x 10 20
Please input the name of the file to be opened: input.txt
Number # 1 is: 1
Number # 2 is: 2
Number # 3 is: 3
Number # 4 is: 4
Number # 5 is: 5
Number # 6 is: 6
Number # 7 is: 8
Number # 8 is: 12
Number # 9 is: 34
Number # 10 is: 10
Number # 11 is: 20
The average of 11 numbers/file = 9.55

OUTPUT SAMPLE #3 for input.txt: xxxxx x x x x xx x x x x x
Please input the name of the file to be opened: input.txt
The file doesn't contain any integers. Exit program!

 

2.  A Java program that reads the file "input.txt" and writes all even values from this file into a new file called "output.txt." 

 

SAMPLE OUTPUT:  

throws  FileNotFoundExceptiontry/catch

OUTPUT SAMPLE #1 for input.txt: xx x xx 10 12 1 3 5 34 x 2 5 7 9 x x 44
Found 11 numbers/file.
Open the file output.txt to get the output.
output.txt: 10 12 34 2 44 

OUTPUT SAMPLE #2 for input.txt: xx xx xx  x  x x xxx xxx
The file doesn't contain any integers. Exit program!

OUTPUT SAMPLE #1:  
Please input the name of the file to be opened: input.tx
--- File Not Found! ---

OUTPUT SAMPLE #2 for input.txt: xx x xx 10 12 1 3 5 34 x 2 5 7 9 x x 44
Please input the name of the file to be opened: input.txt
Found 11 numbers/file.
Open the file output.txt to get the output.
output.txt: 10 12 34 2 44

OUTPUT SAMPLE #3 for input.txt: xx xx xx  x x xxx x xx x x x
Please input the name of the file to be opened: input.txt
The file doesn't contain any integers. Exit program!





Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java Concepts Late Objects

Authors: Cay S. Horstmann

3rd Edition

1119186714, 978-1119186717

More Books

Students also viewed these Programming questions

Question

Do Question 16 if r = .035 and / = .04. AppendixLO1

Answered: 1 week ago

Question

What does the slope in a simple linear regression model measure?

Answered: 1 week ago