JSP and HTML form to convert fahrenheit to celsius using java
Create an HTML form that prompts the user to enter a height in feet. When the
form is submitted, a JSP web page should run that displays the height converted
to inches. The height in inches is Foot * 12 Inches.
Answer:
/** * JSP and HTML form to convert fahrenheit to celsius. */ File: TempConvert.html <HTML> <HEAD> <!-- Convert fahrenheit to celsius. --> <TITLE>Temperature Converter</TITLE> </HEAD> <BODY> <FORM method=post action="question10.jsp"> Input a temperature in Fahrenheit. <input type=text name=fahr> <input type=submit value="Submit"> </FORM> </BODY> </HTML> File: question.jsp <html> <title>Fahrenheit to Celsius</title> <body> <% String s = request.getParameter("fahr"); double fahr = Double.parseDouble(s); double celsius = 5 * (fahr - 32) / 9; out.println(fahr + " converted to Celsius is " + celsius); %> </body> </html> <!—End of Question -->
Leave a reply