JavaScript Project – Temperature Converter

Full Stack Web Development Courses with Real-time projects Start Now!!

Program 1

// Temperature Converter 
// fahrenheit=((celsius*9)/5) +32
// celsius=((fahrenheit-32)*5)/9
  
 let c=23.45  
 f=((c*9)/5) +32
console.log("fahrenheit temperature is : "+f)


Program 2

<html>
    <head><title>Temperature Converter</title>
         <script language="javascript">
            function ctof()
            {
                 let c,f
                 c=document.getElementById("cel").value  
                 f=((c*9)/5) +32
                  //alert(f)
                    document.writeln("<center>")
                    document.writeln("<font color=red size=6>Fahrenheit temp: "+f+"</font>")
                    document.writeln("</center>")   
            }
         </script>
    </head>
    <body>
       <center>
        <form>
             <table border=1>
                <tr>
                    <th>Celsius: </th>
                    <td><input type=text name=txt1 id="cel"></td>
                    <td></td>
                    <td><input type="button" value="Fahrenheit" onclick="ctof();" ></td>
                </tr>
             </table> 
           </form>  
        </center>
    </body>
</html>

 

Did we exceed your expectations?
If Yes, share your valuable feedback on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *