Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this lab you will write 2 programs, given below [DNote: you must write 2 versions one that throws the RileNotEoundRxceetion exception and one that

image text in transcribed
For this lab you will write 2 programs, given below [DNote: you must write 2 versions one that throws the RileNotEoundRxceetion exception and one that handles the exception (try/catch)]. Also, make sure that your programs handle (consume) unwanted input Your programs should produce the expected output listed below First, create a file called "input.txt" that contains a sequence of integer values separated by one or more spaces or returns. You can use the Notepad to create the file. When you save the program choose the "text file" option and name your file "input" because Notepad will automatically append the extension.txt". Put this file in the folder you are going to use for the following Java programs (anyway, know where your text file is located, so that you can give a full path in case it isn't in the same folder as your Java program). You will use this file in the programs below. 1. Write a Java program that reads the file "input.txt" and calculates and prints the average of all integer numbers in this file. Expected OUTPUT: throws FileNet try/catch OUTPUT #1 for input.txt : 1 2 3 4 5 OUTPUT #1 for input.txt. 1 2 3 4 16 x 8 12 x 34 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 # B is: 12 |Number # 9 is: 34 Number # 10 is: 10 Number # 11 is: 20 The average of 11 numbers/fileThe average of 11 numbers/file 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 ber # 8 is: 12 umber # 9 is: 34 Number # 10 is: 10 Number # 11 is: 20

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_2

Step: 3

blur-text-image_3

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

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

5. Develop a self-management module for a training program.

Answered: 1 week ago