CS101 Assignment 2 Solution Fall 2018
#1
CS101 - Introduction to Computing

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>
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  CS101 GDB Solution Mishi Khan 0 189 02-05-2019, 11:27 PM
Last Post: Mishi Khan
  Assignment 2 solution Asifa Asghar 0 85 01-31-2019, 05:05 PM
Last Post: Asifa Asghar
  Assignment solution Asifa Asghar 0 41 01-31-2019, 05:02 PM
Last Post: Asifa Asghar
  Cs101 GDB 2018 Bia Fatima 3 3,241 01-27-2019, 11:57 AM
Last Post: Admin
  Assignment 2 solution Asifa Asghar 0 82 01-25-2019, 12:14 AM
Last Post: Asifa Asghar
  Assignment solution Asifa Asghar 1 164 01-23-2019, 10:30 PM
Last Post: Admin
  Assignment solution Asifa Asghar 1 81 01-23-2019, 10:29 PM
Last Post: Admin
  CS101 Assignment 3 Solution Spring 2018 Mehar Hasnain Awan 0 1,706 07-16-2018, 10:00 PM
Last Post: Mehar Hasnain Awan
  CS101 Assignment 2 Solution Spring 2018 Admin 2 3,494 05-28-2018, 09:12 PM
Last Post: Admin
  CS101 Assignment Solution Spring 2018 Admin 3 3,799 05-26-2018, 07:48 PM
Last Post: Syed Saif Ul Ejaz



Users browsing this thread:
1 Guest(s)