Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

TCSS 142 Object-Oriented Programming Winter 2020 Assignment #5 Due 21 February 2020 Value: 5% of the course grade This assignment includes one problem with two

image text in transcribed

TCSS 142 Object-Oriented Programming Winter 2020 Assignment #5 Due 21 February 2020 Value: 5% of the course grade This assignment includes one problem with two opportunities for extra credit. You will write an interactive application called 'Temperatures.java' which reads a file containing temperatures in degrees Celsius (one temperature per line). Your program will report the number of temperatures included in the file, the average temperature, the lowest temperature, and the highest temperature. The output will be reported on the console and written to an output file named 'output.txt'. All values in the output should be displayed with 2 decimal places using printf. (Do NOT actually round the values in your program, just display rounded values). Your program must prompt the user for the name of the input file. I have provided 4 input files for you to use in your testing. You may create additional test files if you choose. If the user requests an input file that cannot be found, your program should give an error message and prompt again repeatedly until the user enters a valid file name. NOTE: You can use the boilerplate code to open a file shown on page 408 but you must either modify it to catch the exception or you must catch the exception in main(). Do NOT throw any exceptions from main. Information about catching exceptions is shown in Appendix D. The code example I provided in class also shows exception handling. In addition to the main method, your program must include separate methods to display an introduction, prompt for the input file name, and provide output. There should not be any print statements in main and you must not throw any exceptions from main. You may create additional methods, if you choose, to improve the structure your program. Here is sample output from a working solution to this problem (user input is in bold): This program reports the following statistics about a file of Celsius temperatures: the number of temperatures in the file the average temperature the minimum temperature the maximum temperature Input file name? someFile.txt File not found. Please try again. Input file name? anyFile.dat File not found. Please try again. Input file name? CTemps1.txt Number of temperatures: 30 Average temperature: 8.44 Minimum temperature: 4.25 Maximum temperature: 14.91

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

T Sql Window Functions For Data Analysis And Beyond

Authors: Itzik Ben Gan

2nd Edition

0135861446, 978-0135861448

More Books

Students also viewed these Databases questions