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
  Cs101 GDB 2018 Bia Fatima 1 2,919 08-02-2018, 08:05 AM
Last Post: Admin
  CS101 Assignment 3 Solution Spring 2018 Mehar Hasnain Awan 0 1,545 07-16-2018, 10:00 PM
Last Post: Mehar Hasnain Awan
  CS101 Assignment 2 Solution Spring 2018 Admin 2 3,075 05-28-2018, 09:12 PM
Last Post: Admin
  CS101 Assignment Solution Spring 2018 Admin 3 3,608 05-26-2018, 07:48 PM
Last Post: Syed Saif Ul Ejaz
  CS101 Quiz 2 Syed Azhar Hussain Bukhari 2 2,451 01-23-2018, 11:33 AM
Last Post: Admin
  CS101 Assignment 1 Solution Fall 2017 Pakistani 9 7,335 11-06-2017, 06:28 PM
Last Post: muhammadhamza2222
  CS101 assignment solution Rubaisha(Moody Girl) 0 1,224 07-31-2016, 06:17 PM
Last Post: Rubaisha(Moody Girl)
  Cs101 solution Rubaisha(Moody Girl) 0 1,170 05-08-2016, 10:20 PM
Last Post: Rubaisha(Moody Girl)

Users browsing this thread:
1 Guest(s)