# Project Five The Temperature Statistics Problem Write a program to produce the statistics for temperatures stored in a file.

Project Five The Temperature Statistics Problem Write a program to produce the statistics for temperatures stored in a file. The centigrade temperatures in the file are the monthly averages for 12 months (January to December) in Cuba.

Here is a sample displaying the required report:

————————————–

Average Temperature: 25.22

High Temperature: August 27.80

Low Temperature: January 22.20

Temperature Statistics in Fahrenheit

————————————–

Average Temperature: 77.39

High Temperature: August 82.04

Low Temperature: January 71.96

Part I main Driver – TempDriver main should follow this sequence: 1. Declare an array of 12 doubles.

2. Declare a string with a value like this.

It is the path where the temp.dat file is stored. String filePath = “e:temp.dat”; This temp.dat file is included with the assignment. Download and save the file on a storage device. You may need to change the drive designation in the string, depending on where you store the file. Windows 10 requires that a file be in a folder so this may be the path: c:foldertemp.dat Mac Users (file path)  Use the forward slash to separate directories instead of the back slash.  Enter something like this if the file is on the desktop: /Users/Name/Desktop/temp.dat  The directory name and file name are case sensitive so you must use a capital letter where applicable.

3. Call the readFile method that is part of the main driver file.

The readFile method receives the file path string and an array from main, and reads the file data into the array. Use the FileIO file in the Chapter Seven materials as an example of reading file data into an array. The FileArrayExcept file in the Chapter Ten materials is an example of displaying possible error messages.

Display an error message if the file is not found and add this statement after displaying the error message: System.exit(-1); Here is the structure of TempDriver before adding the Temp class code.

Class – Temp Write a class to perform the statistics for any array of 12 temperatures. The Temp Class –

Be sure to write and test one method at a time. Copy/paste the months array at the top of the class with the other private declarations. private String [] months = {“January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”};

Temp has these instance variables in the constructor:

double arr[] will be assigned the array values passed to it from main.

double avg = assign 0

int maxIndex = assign 0

int minIndex = assign 0

Temp contains these methods.

 calcAvg method calculates the average of the values in arr, sets avg equal to the result, and returns the average, which is a double.

 findMax method finds the maximum value in arr and its index in the array. maxIndex in the constructor is set to the index of the maximum value. The method returns the maximum value, which is a double. Write the code assuming the values are not in ascending order. Do not sort the values.

 findMin method finds the minimum value in arr and its index in the array. minIndex in the constructor is set to the index of the minimum. The method returns the minimum value, which is a double. Write the code assuming the values are not in ascending order. Do not sort the values

.  convertToFah uses the array (arr) in the constructor to convert the Centigrade values to Fahrenheit. Use a for loop to adjust the values in arr. The formula for converting Centigrade to Fahrenheit is Fahrenheit = Centigrade * 9.0/5.0 + 32; You will need to use this method before displaying the temperatures in Fahrenheit.

Page 4  toString method creates the output string using the instance variables in the constructor: See page 1 for the required output.

Use DecimalFormat (Chapter Three) to display 2 decimals. Here is how you should approach the code in the Temp class. o Declare the instance variables. o Code the constructor. o Add the appropriate code to main. o

Add a for loop in the constructor to display the array arr to see that the values are correct. o Do not add any more code until the arr array contains the correct values. o Code the calcAvg method. o Create the code in toString to display just the average until it works correctly. o Add the appropriate code to main. o Code the findMax method. o Do not code findMin until findMax works. o Code the convertToFah method. All names in bold must be used as specified.

(550 words)

Approximate price: \$22

## How it Works

1

It only takes a couple of minutes to fill in your details, select the type of paper you need (essay, term paper, etc.), give us all necessary information regarding your assignment.

2

Once we receive your request, one of our customer support representatives will contact you within 24 hours with more specific information about how much it'll cost for this particular project.

3

After receiving payment confirmation via PayPal or credit card – we begin working on your detailed outline, which is based on the requirements given by yourself upon ordering.

4

Once approved, your order is complete and will be emailed directly to the email address provided before payment was made!