Reference no: EM132238036
Scripting for Design Assignment - Functions
OVERVIEW: Your task in this assignment is to create a JavaScript program that converts three Centigrade temperatures to three Fahrenheit temperatures.
The JavaScript code will work with four HTML elements:
- 2 input elements for the input i.e. Centigrade temperature values.
- 1 div element for the output i.e. Fahrenheit temperature values.
- 1 button element to start the process.
Completion of the assignment will require coding two functions:
1. an onclick function that is connected to the button (as before).
2. a programmer defined function named convertToFahrenheit which will return a Fahrenheit temperature given the Centigrade value.
The code required for convertToFahrenheit is essentially the same as the convertToCentigrade function example provided in the TOPIC 4 notes, with the temperature scales reversed. The main change is the expression used to do the conversion. In the convertToFahrenheit function the expression to convert a Centigrade temperature to Fahrenheit is: 1.8 * degCentigrade + 32, where degCentigrade is the only parameter used by the function.
The input will consist of two Centigrade values, a base temperature and an increment. These two will determine the three Centigrade temperatures to convert. For example if a base temperature of 10 and an increment of 5 are entered then the code would convert 10oC, 15oC, and 20oC to their Fahrenheit equivalents i.e. it starts at 10 and bumps it up by 5, twice.
Therefore if the variables baseTemp and incrTemp are used to store the input values, the program would have to convert the three temperatures:
baseTemp
baseTemp + incrTemp
baseTemp + 2 * incrTemp
In summary, when the button is clicked the code that makes up the onclick function will:
1. input values from the text fields into variables
2. parse the input values
3. call the convertToFahrenheit function three times to convert the three Centigrade temperatures to Fahrenheit
4. round the Fahrenheit values to whole numbers
5. format and output the results to the div.
NOTE: Your objective is to code the JavaScript statements to produce the required structure, content, and especially the behavior.
Attachment:- Assignment File.rar