Home Jsp Simple-jsp-example Convert Celsius to Fahrenheit
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Convert Celsius to Fahrenheit

Advertisement
Celsius is a unit to measure temperature scale on which water freezes at 0 degree and boiling point is 100 degree.

Convert Celsius to Fahrenheit

        

Celsius is a unit to measure temperature scale on which water freezes at 0 degree and boiling point is 100 degree. This unit is discovered by Celsius in 1742, a Swedish astronomer and physicist, he has invented the centigrade, or Celsius thermometer divided between the freezing and boiling points of water into 100 parts. 

Fahrenheit Scale was invented by Daniel Gabriel Fahrenheit , he was the German physicist who invented the temperature scale that was patented by his name Fahrenheit Scale.

In this example you will learn how to convert the temperature Celsius to Fahrenheit. To change the Celsius to Fahrenheit we have the formula Fahrenheit = 32 + 9 * c / 5. To change the Celsius to Fahrenheit we need one html page which will take any value as a Celsius and later this Celsius parameter will be get into the jsp page and the formula will be implemented on  this variable and the result will be displayed to you. All this processing will be done inside the scriptlet directive.  

The code of the program is given below.

<html>
<head>
<title>Convert Celsius to Fahrenheit Jsp</title>
</head>
<body>
<table border="1" cellpadding="0"
   cellspacing="0" width="35%" align="center">

  <tr>
    <td width="100%">
     <p align="center"><b>Convert Celsius to Fahrenheit Jsp</b></p>
     <form method="POST" action="Celsius-to-Fahrenheit.jsp">
       
        <p align="center"><b>Enter Temprature in Celsius:</b>
	<input type="text" name="cel" size="20">
        <input type="submit" value="Convert" name="B1"></p>
        </form>
      <%
		String str=request.getParameter("cel");
			if(str == null || str.equals("")){ 
			   out.println("<b>Fahrenheit:</b>");
			}
			else{
			 float c=Float.parseFloat(str);
			float f = 32 + 9*c/5;
			out.println("<b>Fahrenheit:</b>"+f);
			}%>
	  <p>&nbsp;</p></td></tr>
  </table>
</body>
</html>

Output:

Download this example.
 
Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 6, 2008

Ask Questions?    Discuss: Convert Celsius to Fahrenheit   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
sarweswaran
June 15, 2011
convert celcius

it is very good
DMCA.com