Lab Assignment 1 Answer Sheet
Lab Assignment 1 Answer Sheet
PROGRAMMING
(CSC415)
LAB ASSIGNMENT 1
(Topic 2-5%)
Questions
1) Calculate the net salary for a worker. The net salary is the different of gross salary and
total deduction. The gross salary is the total of basic salary and total allowances. The
allowances are housing allowance, telephone allowance and transportation. Each of
allowance is RM500, RM700, and RM750. The worker has to contribute to EPF
deduction 9% of gross salary and contribution for SOCSO 2% of gross salary. Display the
worker name, employee id, basic salary, total allowances, gross salary, total deduction,
and the net salary that he/she get. Then display the employee salary information as an
example below:
Page 3 of 5
CODING
#include<iostream>
using namespace std;
int main()
{
//input
int total_allowances, gross_salary;
double total_deduction, net_salary;
int housing_allowance = 500;
int telephone_allowance = 700;
int transportation = 750;
int basic_salary = 10000;
//process
total_allowances = housing_allowance + telephone_allowance + transportation;
gross_salary = basic_salary + total_allowances;
total_deduction = (0.09*gross_salary) + (0.02*gross_salary);
net_salary = gross_salary - total_deduction;
//output
cout<<" Employee Salary Information"<<endl;
cout<<" "<<endl;
cout<<"Name : Khairunnisa Bt Abdul Kadir"<<endl;
cout<<"Employee ID : 20154231"<<endl;
cout<<" "<<endl;
cout<<"Basic Salary : "<<"RM "<<basic_salary<<".00"<<endl;
cout<<"Total Allowances : "<<"RM "<<total_allowances<<".00"<<endl;
cout<<"Gross Salary : "<<"RM "<<gross_salary<<".00"<<endl;
cout<<"Total Deduction : "<<"RM "<<total_deduction<<"0"<<endl;
cout<<"Net Salary : "<<"RM "<<net_salary<<"0"<<endl;
return 0;
}
Page 4 of 5
OUTPUT SCREEN
Page 5 of 5
RUBRICS
Input Statement 3
Output Statement 5
Process 8
Structure of Codes 2
(pre-processor,
comments,
declaration
variables, good
styles)
Output Screen 2
Total 20