Click here to Skip to main content
13,830,913 members
Rate this:
Please Sign up or sign in to vote.
See more:
Create an Employee class with the following specifications.
1. EmployeeName as string.
2. BasicSalary, HRA, DA, TAX, GrossSalary and NetSalary as double.
3. Calculate the HRA (15% of BasicSalary), DA (10% of BasicSalary), GrossSalary (BasicSalary + HRA + DA), Tax (8% of GrossSalary) and NetSalary (GrossSalaryTax).
4. A Constructor to define the EmployeeName and BasicSalary.
5. A method CalculateNetPay to calculate the HRA, DA, Tax, GrossSalary and NetSalary values using the criteria mentioned in the Point 3.
6. A method Display to display the Salary structure.

How can I do this calling?
in c#

What I have tried:

calculating salary details using should I call it using parameters
Updated 15-Apr-18 23:29pm
CPallini 16-Apr-18 4:17am
You should show us your code in order to get help.
Maciej Los 16-Apr-18 4:21am
What stops you?
Richard MacCutchan 16-Apr-18 4:33am
GrossSalary and NetSalary are calculated values so they do not need to be members of the class.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

calculating salary details using should I call it using parameters
Well, that will depend on exactly what parameters you define your method as requiring!
Presumably, you pass it the Basic Salary, and it "fills in the blanks" in your class.
If so, then it will have a signature like this:
public void CalculateNetPay(double basicSalary)
So you would call it passing either a constant value:
Or a variable containing the value:
double basicPay;
if (!double.TryParse(stringContainingUserEnteredSalary, out basicPay))
   // Report problem to user

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.190114.1 | Last Updated 16 Apr 2018
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100