Purpose of the assignment
To apply simple JavaScript concepts to create a Fahrenheit to Celsius (and Celsius to Fahrenheit)
conversion program. I need both please!
What’s required of you.
Having looked at some basic examples of JavaScript on
http://www.w3schools.com and at the
“simple math with forms/inputs and validation” example in detail , I would like you to now
apply those concepts to create a simple page that lets users type in some temperature value in
the Fahrenheit/Celsius scale and when the user clicks a “Show Results” button the program
shows the equivalent temperature in the other scale. For example, if the user types in 32
Fahrenheit the results show “0 degrees Celsius”.
Note
: Before you begin, create a file called “temperature.html” on your desktop. From now on
save everything in this file.
Functionality
At the least your program should allow for the following:
I.
User Input:
One text field where the user will type in the temperature in Fahrenheit
II.
Input Validation: When the “Show Results” button is clicked, your program should
check to see if the user has left the text field empty.
III.
If there is a problem (as in II. Above), then your program should show appropriate
error message. (Don’t worry about other checks for the summer session).
IV.
Display Results: If there are no errors and user input is valid, then your program
should show the result to the user.
Here is the temperature.html file for Fahrenheit to Celsius convert. Celsius to Fahrenheit converter is in temperature2.html given below. The code have been commented out for explanation. If still you have any doubts please ask me.
temperature.html:
<!DOCTYPE html>
<html>
<head>
<title>Fahrenheit to Celsius Covertor</title>
<script>
function convert() {
//Get value from input text field
var far = document.getElementById('frnt').value;
//if input is empty
if(far== ""){
//output message
document.getElementById('output').innerHTML = "Plese enter some number";
return
}
//convert to celsius
var cel = (far - 32) * 5 / 9;
document.getElementById('output').innerHTML = "Celsius: "+cel;
}
</script>
</head>
<body >
<h1>Fahrenheit to Celsius Covertor</h1>
<!-- create a form that has one input field ,, one span fiend and one buton
on submit call the convert function of javascript -->
<form action="javascript:convert()">
Temperature in Fahrenheit: <input type="number" id="frnt" name="fahrenheit">
<span id="output"></span>
<br><br><input type="submit" value="Convert">
</form>
</body>
</html>
Screenshot:
Outputs:
termperature2.html:
<!DOCTYPE html>
<html>
<head>
<title>Celsius to Fahrenheit Covertor</title>
<script>
function convert() {
//Get value from input text field
var cel = document.getElementById('frnt').value;
//if input is empty
if(cel== ""){
//output message
document.getElementById('output').innerHTML = "Plese enter some number";
return
}
//convert to Fahrenheit
var far = (cel * 9 / 5) + 32;
document.getElementById('output').innerHTML = "Fahrenheit: "+far;
}
</script>
</head>
<body >
<h1>Celsius to Fahrenheit Covertor</h1>
<!-- create a form that has one input field ,, one span fiend and one buton
on submit call the convert function of javascript -->
<form action="javascript:convert()">
Temperature in Celsius: <input type="number" id="frnt" name="celsius">
<span id="output"></span>
<br><br><input type="submit" value="Convert">
</form>
</body>
</html>
Screenshot:
Output:
Purpose of the assignment To apply simple JavaScript concepts to create a Fahrenheit to Celsius (and...
This program will take the user's input as a temperature in degrees Fahrenheit. The user will then click a radio button indicating whether a table of temperatures, starting with the entered value, will be displayed in increments of 5 degrees F or 10 degrees F. When a submit button is clicked your code will display a HTML table of temperature values. The first column will be temperatures in degrees Fahrenheit, given in increments of 5 or 10 degrees F, depending...
C# Temp. Converter program. Create a Celsius and Fahrenheit Temperature Converter application. The application must have 2 Labels (each one of them assigned only to Celsius and Fahrenheit), 2 TextBoxes (each one of them assigned only to Celsius and Fahrenheit), only 1 Convert Button, 1 Clear Button, and 1 Exit Button. Also, 1 Error message label which will display the error messages. The application should only allow the user to enter the desired temperature just in one of the TextBoxes...
FOR PYTHON Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom functionc_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places. Custom function f_to_c should be a...
Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom function c_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places. Custom function f_to_c should be a value-returning...
in matlab Fahrenheit and Celsius are related by equation: TeT 32)/1.8 Create a function called tempConv that will convert temperature between Fahrenheit and Celsius The function should have two input parameters: one is a single temperature in degrees and the other one is the input temperature scale character 'C'or 'F The function should return the converted temperature as variable temp
Create a program in Python that will allow the user to enter a temperature in Fahrenheit which will then be converted to degrees Celsius. The program will keep asking the user for a Fahrenheit temperature until the user enters Q to quit. After each conversion the program needs to print out the degrees Celsius. The input prompts for this problem need to look like the following: Degrees Fahrenheit: Continue: For these input prompts watch the capitalization and spacing. There are...
Temperature Converter Create a temperature conversion program that will convert the following to Fahrenheit: Celsius Kelvin Newton Your program should take a character which represents the temperature to convert from and a value to be converted to using the following specification: C - Celsius K - Kelvin N - Newton In addition your program should take in the following character to exit the program: X - eXit the program The numeric input for your program should be of type double....
Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom function c_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places. Custom function f_to_c should be a value-returning...
The purpose of this assignment is to create a program that works like a simple html file converter. Your program will read a text file and will produce an html file that can be viewed using a web browser, like Mozilla Firefox or Internet Explorer. Write code that converts an input file, myfile, into a simple Hyper Text Markup Language (HTML) file, myfile.html. In order to do this, you will read the input file, myfile, from the beginning to the...
In this Final program you are going to use several concepts you learned in CSC 101 class, especially operations on or using FILES , LOOPS and FUNCTIONS. You need to implement C++ code that will read data from a file and process it as outlined below and write the processed data to an output file. You can refer to the file input.txt for how the data is made available to you and output.txt for how to write out the processed...