使用以下规范创建员工类。 1. Employeename为字符串。 2.基础知识,HRA,DA,TAX,grosssalary和netsalary为double。 [英] Create an employee class with the following specifications. 1. Employeename as string. 2. Basicsalary, HRA, DA, TAX, grosssalary and netsalary as double.
问题描述
使用以下规范创建 Employee
类。
1. EmployeeName
as字符串。
2. BasicSalary
, HRA
, DA
, TAX
, GrossSalary
和 NetSalary
双倍。
3.计算 HRA
(15%的 BasicSalary
), DA
(10%的 BasicSalary
), GrossSalary
( BasicSalary
+ HRA
+ DA
),税
(8%的 GrossSalary
)和 NetSalary
( GrossSalary
- 税
)。
4.用于定义 EmployeeName
和 BasicSalary
的构造函数。
5.方法 CalculateNetPay
计算 HRA
, DA
,税
, GrossSalary
和 NetSalary
使用第3点中提到的标准的值。
6.方法显示
以显示薪水
结构。
如何拨打电话?
in c#
我尝试了什么:
使用方法计算工资详情。我应该使用参数
引用:计算工资详情使用方法...我应该如何使用参数调用它
那么,这将取决于您定义方法所需的确切参数!
据推测,您将基本工资传递给它,并且它会在你的课堂上填空。
如果是这样的话,它会有这样的签名:
< pre lang =c#> public void CalculateNetPay( double basicSalary)
{
...
}所以你要称它传递一个常数值:
< pre lang =c#> CalculateNetPay( 45000 。 0 );或包含值的变量:
double basicPay;
if (!double.TryParse(stringContainingUserEnteredSalary, out basicPay))
{
// 向用户报告问题
...
< span class =code-keyword> return ;
}
CalculateNetPay(basicPay);
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
(GrossSalary
– Tax
).
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 method...how should I call it using parameters
Quote:calculating salary details using method...how 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:
CalculateNetPay(45000.0);Or a variable containing the value:
double basicPay; if (!double.TryParse(stringContainingUserEnteredSalary, out basicPay)) { // Report problem to user ... return; } CalculateNetPay(basicPay);
这篇关于使用以下规范创建员工类。 1. Employeename为字符串。 2.基础知识,HRA,DA,TAX,grosssalary和netsalary为double。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!