This program uses arrays and functions to input multiple data items (temperatures) that are each within a certain range and then output some information about them.
1. The program will input from 1 to 20 (inclusive) Fahrenheit temperatures from the user. You must first ask them to enter the number of temperatures that they will be typing in. If the value entered is not between 1 and 20, you need to display a message informing the user that the value they entered is out of range and make them re-input until they provide an acceptable value.
2. The Fahrenheit values are doubles and must range between -100.0 and 150.0 (inclusive.) If an out-of-range temperature is entered, you must display a message informing the user as such and have them re-input until an in-range value is entered.
3. Display all values in ascending order as both Fahrenheit and Celsius values.
4. Display the average in Fahrenheit and Celsius, followed by the highest and lowest temperatures (in Fahrenheit and Celsius.)
5. Finally, output the amount of Fahrenheit temperatures (not the actual temperatures, just how many) that fall within the specified gradations.
a) Certain tasks must be put in their own function and each of the functions listed below must be part of your program. Each function needs to handle just its primary task (e.g. no output unless it’s specified). Redundant work and/or doing any of the assigned function’s work elsewhere (e.g. main()) will incur a significant penalty. You may add other functions that do tasks not listed here.
void inputFahrs(double data, int numFahrs) – prompts and inputs numFahr values within the specified range (enforced.)
double fahrToCels (double fahr) – takes in a Fahrenheit temperature and returns the corresponding Celsius value.
void outputFahrs(double data, int numFahrs) – outputs a descriptive header followed by all of the Fahrenheits in ascending order, one on a line, alongside the corresponding Celsius value.
void outputAverage (double data, int numFahrs) – outputs the average of all the values in the array in Fahrenheit and Celsius.
void outputHighLows (double data, int numFahrs) – Outputs the high and low values as both Fahrenheit and Celsius.
void outputGrads (double data, int numFahrs) – Outputs how many Fahrenheit values belong to each of the following gradations:
i. Below 0.0
ii. Between 0.0 and 32.0 (inclusive)
iii. Above 32.0 and less than 68.0
iv. At least 68.0 and less than or equal to 100.0
v. Above 100.0
b) Display all floating-point (double) numbers to one decimal place.
c) All output needs to be right-justified and aligned by the decimal point (see below.)
d) The first line of your output must be your name, followed by “Assignment 2”.
e) Use blank lines to separate your output and label each piece of output.
f) You are expected to use standard style guidelines (e.g. alignment of braces, indention, etc.) as covered in class. Use white space generously within statements where it will be helpful (e.g. on either side of arithmetic operators.) Leave one or two blank lines between each function. Lines of code that run into the margin and/or into the next line will be penalized.
CIS 231 - Assignment 2 – Your Name
Average 40.0 4.4
High: 50.0 10.0
Low: 30.0 -1.1