JavaScript Project – Temperature Converter

Free Web development courses with real-time projects Start Now!!

Program 1

let c=12.5
let f=((c*9)/5)+32
console.log("celsius of "+c + " in  fahrenheit is ="+f)  
let f1=54.5
let c1= ((f1-32)*5)/9 
console.log("fahrenheit of "+f1 + " in celsius is ="+c1)

Program 2

<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script language="javascript">
         function ctof()
         { 
            var c,f
             c=document.getElementById("cel").value
             f=((c*9)/5)+32
             alert("Fahrenheit =" +f)
//             document.writeln("<center>")
//             document.writeln("<font color=red size=6>Fahrenheit =" +f +"</font>")
//             document.writeln("</center>")
        } 
        </script> 
    </head>
    <body>
         <center>
             <form>
               <table border="1">  
                   <tr>
                       <th>Celsius: </th>
                       <td><input type="text" name="txtc" id="cel"></td>
                       <td><input type="button" value="Fahrenheit" onclick="ctof();"></td>
                   </tr>    
                    
                   
               </table>    
             </form>    
         </center>
    </body>
</html>

 

Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google

follow dataflair on YouTube

Leave a Reply

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