01-23-2019, 10:29 PM
CS101 - Introduction to Computing
Assignment 2 Solution
Semester: Fall 2018
Solution
Assignment 2 Solution
Semester: Fall 2018
Solution
Code:
<html>
<html>
<head>
</head>
<style>
h1{
background-color: #007FFF;
text-align: center;
}
h3{
background-color: #32a96c;
text-align: center;
}
</style>
<body>
<h1>Employee Salary Calculator</h1>
<h3>Welcome to Online Salary Calculator</h3>
<center>
<table>
<tr>
<td><label>Employee ID:</label></td>
<td><input type="text" value="BC180403203"></td>
</tr>
<tr>
<td><label>Employee Name:</label></td>
<td><input type="text" value="AYAN MALIK"></td>
</tr>
<tr>
<td><label>Father Name:</label></td>
<td><input type="text" value="MALIK AKBAR"></td>
</tr>
<tr>
<td><label>Gender:</label></td>
</tr>
<tr>
<td><label>Male</label></td>
<td><input type="radio" checked></td>
</tr>
<tr>
<td><label>Female</label></td>
<td><input type="radio"></td>
</tr>
<tr>
<td><label>CNIC:</label></td>
<td><input type="text" value="36301-8899900-1"></td>
</tr>
<tr>
<td><label>Basic Salary*:</label></td>
<td><input type="text" id="basic"></td>
</tr>
<tr>
<td><label>Utilities*:</label></td>
<td><input type="text" id="utilities"></td>
</tr>
<tr>
<td><label>House Rent*:</label></td>
<td><input type="text" id="house_rent"></td>
</tr>
<tr>
<td><label>Tax Percentage*:</label></td>
<td><input type="text" id="tax_percentage"></td>
</tr>
<tr>
<td><label>Total Salary*:</label></td>
<td><input type="text" id="total_salary"></td>
</tr>
<tr>
<td><label>Tax Year:</label></td>
<td><select>
<option>2014</option>
<option>2015</option>
<option>2016</option>
<option>2017</option>
<option>2018</option>
</select></td>
</tr>
<tr>
<td><input type="submit" onclick="SalCal();" value="Calculate"</td>
<td><input type="reset" onclick="reset()" value="Clear"></td>
</tr>
</table>
</center>
<script>
// reset button with pure javascript
function reset(){
location.reload();
}
function SalCal(){
var basic_salary = document.getElementById('basic').value;
if(basic_salary == ''){
alert('Basic salary is missing');
}else{
var utilities_input = basic_salary * 10 / 100;
utilities.value = utilities_input;
var house_rents = basic_salary * 8 / 100;
house_rent.value = house_rents;
var tax_percentages = basic_salary * 2/ 100;
tax_percentage.value = tax_percentages;
var total_salaries = (utilities_input + house_rents) + (basic_salary - tax_percentages);
total_salary.value = total_salaries;
}
}
</script>
</body>
</html>