CS101 Assignment 3 Solution
CS101 - Introduction to Computing
Assignment 3 - Spring 2017

Problem Statement: Create a Temperature Converter webpage with only HTML and JavaScript. It must convert user entered value from Fahrenheit to Celsius and vice versa.  Output must be an Integer and you must not use Math.round() function. There should not be a button, but a statement that shows whether the user has selected Fahrenheit or Celsius for conversion from the drop down list. 
Screenshots are given in the assignment file.

Copy the following code and paste it in the notepad in your computer, only use notpad and not wordpad or Microsoft Word. Click on File option and then Save the file with extension .html e.g. yourname.html 
<title>Student Id: "Write your student ID here"</title>
<h1>Convert temprature</h1>
        <td>Enter a value:</td>
        <td><input type="text" onChange="myFunction()" name="uvalue" id="uvalue"></td>
            <select name="utype" id="utype" onChange="myFunction()">
                <option value="b">Fahrenheit (F&deg;)</option>
                <option value="a">Celsius (C&deg;)</option>
        <td><input type="text" name="answer" id="answer"></td>
        <td colspan="2"><p id="bottomline"></p></td>
        function myFunction()    {
    var w;
    var x = document.getElementById('uvalue').value;
    var y = document.getElementById('utype').value;
    function RoundNum(number){
   var a = number % 1;
   return number-a+(a/1+1.5>>1)*1

        if(y == "a"){
            document.getElementById('bottomline').innerHTML = "You Selected: Celsius to Fahrenheit";
            w = x * 9 / 5 + 32;
            document.getElementById('answer').value =  RoundNum(w);
        if(y == "b"){
            document.getElementById('bottomline').innerHTML = "You Selected: Fahrenheit to Celsius";
            w = (x -32) * 5 / 9;
            document.getElementById('answer').value =  RoundNum(w);

Write your Student ID in the title tag where suggested. 
Remember to save the file with .html extension.
Thank u soooooooooo much Rana
(07-08-2017, 07:58 PM)Khadija Wrote: Thank u soooooooooo much Rana

You're welcome. And do make sure to change the assignment and do not only copy/paste as it is. Or you will be graded ZERO marks.

Possibly Related Threads...
Thread Author Replies Views Last Post
  CS604 Assignment 3 Solution Pakistani 2 206 07-26-2017, 06:17 PM
Last Post: Rubaisha(Moody Girl)
  CS507 Assignment solution Rubaisha(Moody Girl) 0 144 07-25-2017, 10:23 PM
Last Post: Rubaisha(Moody Girl)
  CS601 Assignment 4 Solution Rana 0 461 07-24-2017, 11:49 AM
Last Post: Rana
  CS401 Assignment 3 Solution Pakistani 0 270 07-21-2017, 01:34 PM
Last Post: Pakistani
  CS504 Assignment 3 Rana 7 948 07-19-2017, 08:06 AM
Last Post: Rana
  CS502 Assignment 3 Solution Pakistani 0 292 07-18-2017, 10:00 AM
Last Post: Pakistani
  CS605 assignment-3 Solution Nadeem Rana vu 1 173 07-14-2017, 05:49 PM
Last Post: Pakistani
  CS601 Assignment 3 Solution Pakistani 2 367 07-13-2017, 10:57 AM
Last Post: Rana
  cs 601 Assignment Sadaf Afzal 2 240 07-11-2017, 11:13 AM
Last Post: Pakistani
  CS301 Assignment 3 Solution Pakistani 2 1,035 07-09-2017, 07:13 PM
Last Post: Rana

Users browsing this thread:
1 Guest(s)