Write a function, procedure, and method.
Create simple functions and procedures.
Create fundamental programs using concepts such as functions and arrays.
The terms function, method, and procedure each refer to a concept of modularization where a highly cohesive block of code is referenced by name and is called to perform its specific task. Parameters might or might not be passed to the called code and the called code might or might not return a value to the calling code. The physical structures of these code modules are basically the same in each language using some or all of these terms. Definitions of these terms can vary slightly from language to language. One consistency is with the term method which is usually reserved for such a module of code which is defined as part of a class.
Assignment You will complete a program to demonstrate the skills presented in this lesson for your selected language path. Please keep in mind that with all the assignments in this course, any given scenarios are hypothetical and intended solely to demonstrate specific skills.
Using Java please complete the following:
In this hypothetical scenario your local weather office needs a temporary solution to take a temperature in Celsius, convert it to Fahrenheit, and issue a general statement or warning based on that temperature.
You will build two separate functions. The first will accept the Celsius value and return the temperature in Fahrenheit and the second will accept the Fahrenheit temperature value and use it to determine the appropriate public statement. Another programmer will be writing the GUI. Your role is to create the two functions and test them using six decimal values stored in four different variables.
Define six variables of appropriate data type and assign them the following values: 35.5, 30.5, 22.2, 16.1, 7.3, -1 (notice this last value is negative one)
Write a function that will accept a decimal value representing the Celsius temperature, convert the value to Fahrenheit, and return that Fahrenheit value as a rounded integer value.
Hint 1: The formula to convert from C to F is, TempF = TempC * 9/5 + 32
Hint 2: An easy way to round integer values is to add .5 to the decimal value before converting it to integer.
Write a function that will accept an integer value representing the temperature in Fahrenheit. The function will check the value and determine the correct weather statement to return as a string value. The criteria for these statements are as follows:
>=95F – “A heat advisory has been issued.”
85F to 94F — “Pleasant but warm.”
70F to 84F — “Very pleasant weather today.”
50F to 69F — “Pleasant but cool.”
33F to 49F — “Cold weather.”
<=32F — “A freeze warning has been issued.” For each test variable, call the conversion function followed by a call to the weather statement function. After each call, display to the console the temperature in Celsius and in Fahrenheit followed by the appropriate weather statement as determined by the function. POSSIBLE EXPECTED OUTPUT The temperature is 35.5C or 96F. A heat advisory has been issued. The temperature is 30.5C or 87F. Pleasant but warm. The temperature is 22.2C or 72F. Very pleasant weather today. The temperature is 16.1C or 61F. Pleasant but cool. The temperature is 7.3C or 45F. Cold weather. The temperature is -1C or 30F. A freeze warning has been issued.