ID Auto Generated | Name| Gross Salary | Company | Tax C#
Object
Code
Object
Create a class Employee
having following fields:
a) ID (Auto generated, unique and must not
be manipulated by any other source)
b)
Name
c) GrossSalary
d) Company (same for all objects)
e) Tax (10% and unchangeable)
User should be able to set
"Name", "GrossSalary" and "Company", and get
"Name", NetSalary and "Company" using properties.
Code
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
ConsoleApplication1
{
class
employee
{
int
id;
string name;
double grosssalary;
static string company;
const double tax=0.1;
static
int count;
public employee()
{
COUNT();
}
public void COUNT()
{
count += 1;
id = count;
Console.WriteLine(id);
}
public string employeename
{
set { name = value; }
get { return name; }
}
public double employeegrosssalary
{
set { grosssalary = value;
}
get { return
grosssalary - grosssalary * tax; }
}
public string employeeccompany
{
set { company = value;
}
get { return company;
}
}
}
class
Program
{
static void Main(string[] args)
{
employee e = new employee();
e.employeename = "waki";
e.employeegrosssalary = 10000;
e.employeeccompany
= "shining star";
Console.Write(e.employeename);
Console.WriteLine(e.employeegrosssalary);
Console.WriteLine(e.employeeccompany);
}
}
}
Screen Shot
No comments:
Post a Comment