# VU HELP

Virtual University of Pakistan Study forum !

# Assignment No. 02 Semester: Fall 2017 Introduction to Computing - CS101 Total Marks: 20 Due Date: 12-01-2018

Question Statement:

Note:  Students are required to submit HTML code file only with .html extension.Don’t upload word format file(.doc) etc.

You are required to write HTML with Java Script code to create Weight Converter Calculator web page which can be used to convert values entered in Kilo Gram to Gram, Pounds, Milligrams, US tons and Ounces respectively.

### Solution guidelines of this  web page are given as follow,

You are required to create a text for taking input from the users in Kilo Grams. This text box can be labelled as Weight in KG.

• The users will be required to enter their input in Weight in Kg.
• Create one button labeled as Convert. On Mouse Click event the function “Converter” should be called to covert KG value to other units.
• If no value or less than 0 is entered in KG text box and Covert button is clicked then alert should be shown through window.alert() as:

If the values is greater than 0 then your webpage will show converted values in Grams, Pounds, Milligrams, US tons and Ounces in the given text boxes as shown in sample output.

• Create another button labeled as Reset Form to clear text box values.
• You are required to use table so that items of the webpage will be shown in the arranged form.

Formula for KG to Grams conversion is:

Kilo Grams= KG*1000

Formula for KG to Pounds conversion is:

Pounds = KG* 2.2046

Formula for KG to Milligrams conversion is:

Milligrams = KG* 1000000

Formula for KG to Pounds conversion is:

US Ton = KG* 0.0011023

Formula for KG to Pounds conversion is:

Ounce = KG* 35.274

Sample Output (Snapshot): Color Scheme may be of your choice.

Views: 1717

Attachments:

### Replies to This Discussion

Anyone have solution,

main ny assignment bna li hai or woh theak sy run bhi kr rai hai but i dnt be sure k  send krun ya nai

please dear send me

plz plz dear..

ok i will

what is new instruction in assignment

Solution

Attachments:

# CS101 Assignment solution

<!DOCTYPE html>
<html>

<title>homepage</title>
<script>
function check(){
var x;
x = document.getElementById('in_kg').value;
if (isNaN(x) || x <= 0) {
window.alert("Enter value grater than 0");
}else{
var num;
num = x * 1000 ;
document.getElementById('grams').value = num;
num = x * 2.2046 ;
document.getElementById('pounds').value = num;
num = x * 1000000 ;
document.getElementById('mg').value = num;
num = x * 0.0011023 ;
document.getElementById('Us_ton').value = num;
num = x * 35.274 ;
document.getElementById('ounce').value = num;
}
}
</script>

<body>
<div align="center" style="margin-left: 35%; margin-right: 35%;">
<div style="font-size: 36px; background-color: lightpink; color: Red;">Weight Converter</div>
<p style="font-size: 20px; background-color: blue; margin: 5px;">Welcome to the online converter</p>
</div>
<form align="center">
<table align="center">
<tr>
<td>
<label>Weight in KG:</label>
</td>
<td>
<input type="num" name="kg" id="in_kg">
<input type="button" name="submit" value="Convert" onclick="check()">
</td>
</tr>
<tr>
<td>
<label>Weight In Grams:</label>
</td>
<td>
<input type="num" name="in_g" id="grams">
</td>
</tr>
<tr>
<td>
<label>Pounds:</label>
</td>
<td>
<input type="num" name="in_p" id="pounds">
</td>
</tr>
<tr>
<td>
<label>MilliGram:</label>
</td>
<td>
<input type="num" name="in_m" id="mg">
</td>
</tr>
<tr>
<td>
<label>US Ton:</label>
</td>
<td>
<input type="num" name="in_t" id="Us_ton">
</td>
</tr>
<tr>
<td>
<label>Ounces:</label>
</td>
<td>
<input type="num" name="in_o" id="ounce">
</td>
</tr>
</table>
<div id="grams"></div>
<input type="reset" name="reset" value="Reset Form">

<p>You can press Reset Button for another conversion</p>
</form>

</body>
</html>

## Videos

• ### html student registration form

Added by Hilal Hussain

• ### computer programming friend function in c++

Added by Hilal Hussain

• ### computer science engineering

Added by Hilal Hussain

• ### international conference of virtual university ofpakistan

Added by Hilal Hussain