Write a program using a class that get information about employee rollno, name, address, pin code, phone number, gross salary and pf. Display the net salary (ie gross less pf) and calculate grade base on net salary. The grades are
Grade-‘A’ sal>10000
Grade-‘B’ sal>5000
Grade-‘C’ sal<5000
My code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeClass
{
class EmployeeClass
{
private int _EmployeeID;
private double _GrossPay;
private double _PF;
private int _Pincode;
private double _PhoneNumber;
private string _EmployeeName;
private double _EmployeeAdress;
public int employeeId
{
get
{
return _EmployeeID;
}
set
{
_EmployeeID = value;
}
}
public double grosspay
{
get
{
return _GrossPay;
}
set
{
_GrossPay = value;
}
}
public double pf
{
get
{
return _PF;
}
set
{
_PF = value;
}
}
public int pincode
{
get
{
return _Pincode;
}
set
{
_Pincode = value;
}
}
public double phonenumber
{
get
{
return _PhoneNumber;
}
set
{
_PhoneNumber = value;
}
}
public string employeename
{
get
{
return _EmployeeName;
}
set
{
_EmployeeName = value;
}
}
public double employeeaddress
{
get
{
return _EmployeeAdress;
}
set
{
_EmployeeAdress = value;
}
}
public EmployeeClass(string EName, int EId, int Pincode, int phoneN,double Address, double pf, double grosspay)
{
this._EmployeeName = EName;
this._EmployeeID = EId;
this._Pincode = Pincode;
this._PhoneNumber = phoneN;
this._EmployeeAdress = Address;
this._PF = pf;
this._GrossPay = grosspay;
}
public double CalculateSalary()
{
double netsalary = (this._GrossPay - this._PF);
return netsalary;
}
public void CalculateGrade(string grade, double netsalary)
{
if (netsalary > 1000)
{
grade = "A";
}
else if (netsalary > 5000)
{
grade = "B";
}
else if (netsalary < 5000)
{
grade = "C";
}
}
static void Main(string[] args)
{
EmployeeClass em = new EmployeeClass("Pavan", 123, 48858, 81516615, 303, 1000, 20000);
em.CalculateSalary();
Console.WriteLine("The Net Salary of an Employee is {0}",em.CalculateSalary());
Console.WriteLine("The grade of an Employee is {0}",em.CalculateGrade("A",em.CalculateSalary());
}
}
}