问题: -
假设一家纺织公司“Grace Textile”人力资源(HR)部门。共有80个 3个不同分支的员工。员工分为3类:被拘禁者,合同和永久性 雇员。被拘禁者实习6个月,固定工资,即2万。工资是 按等级计算。合同和永久雇员都有不同的薪级表。 永久员工还享受养老金和小费的优惠。合同员工每月获得一次 薪水和年度额外奖金。 您需要编写一个Java程序,包括: •三类员工,合同员工,永久员工 •员工类将具有“员工ID”,CNIC,姓名,成绩,薪资和基本属性 类别(Internee,合同和永久)。使用“I”代表internee,“C”代表“合同”和 “P”表示永久性 •CNIC的格式为123-456-789 •Contract Employee类将具有Employee类的属性/数据成员和 其他会员“Bonus” •永久Employee类将具有Employee类的属性以及另外2个属性 属性“小费”和“养老金” •为所有数据成员使用适当的数据类型 •写出基类和派生类的显示消息,这些消息将打印相应的Emp Id 类 •为合同员工类编写一个计算奖金的功能。卷数将 存储在一个数组中。滚动号码将是您自己的vu id仅数字(8个数字,不包括前2个 字符)。例如,如果您的卷号为BC12345678,则12345678将存储在数组中。加 所有8位数字并将其命名为“sum”。用公式计算奖金:(sum * 1000)/ 2;打印价值 奖金。
执行代码时出错: -
$javac HelloWorld.java
HelloWorld.java:80: error: illegal start of expression
pension = ;
public class HelloWorld{
public static void main(String []args){
System.out.println("Hello World");
}
}
public class Employee
{
private int id;
private int cnic;
private String name;
private int grade;
private int salary;
private String categ;
public Employee( int employeeId, int employeeCnic, String employeeName, int employeeGrade, int employeeSalary, String employeeCateg)
{
id = employeeId;
cnic = employeeCnic;
name = employeeName;
grade = employeeGrade;
salary = employeeSalary;
categ = employeeCateg;
}
Employee()
{
System.out.println("Enter ID of the Employee:");
id = get.nextLine();
System.out.println("Enter CNIC of the Employee:");
cnic = get.nextLine();
System.out.println("Enter Name of the Employee:");
name = get.nextLine();
System.out.println("Enter Grade:");
grade = get.nextInt();
System.out.println("Enter Salary of the Employee:");
salary = get.nextLine();
System.out.println("Enter Category of the Employee (I, C, P):");
categ = get.nextLine();
}
void display()
{
System.out.println("Employee ID: "+ id);
System.out.println("Employee CNIC: "+ cnic);
System.out.println("Employee Name: "+ name);
System.out.println("Grade: "+ grade);
System.out.println("Salary: "+ salary);
System.out.println("Category: "+ categ);
}
class contractEmployee extends Employee
{
int bonus;
contractEmployee()
{
System.out.println("Enter Grade: ");
grade = get.nextInt();
System.out.println("Enter Salary:");
salary = get.nextFloat();
}
void display()
{
System.out.println("=============================="+"\n"+"Full Time Employee Details"+"\n"+"=============================="+"\n");
super.display();
System.out.println("Salary: "+salary);
System.out.println("Designation: "+ grade);
}
}
class permanentEmployee extends Employee
{
int gratuatiy, pension;
permanentEmployee()
{
System.out.println("Enter Number of Working Hours:");
gratuatiy = get.nextInt();
}
void calculatepay()
{
pension = ;
}
void display()
{
System.out.println("=============================="+"\n"+"Part Time Employee Details"+"\n"+"=============================="+"\n");
super.display();
System.out.println("Number of Working Hours: "+pension);
System.out.println("Salary for "+gratuatiy+" working hours is: $"+pension);
}
}
class Employee
{
public static void main(String args[])
{
System.out.println("================================"+"\n"+"Enter Full Time Employee Details"+"\n"+"================================"+"\n");
permanentEmployee ob1 = new permanentEmployee();
contractEmployee ob = new contractEmployee();
System.out.println("================================"+"\n"+"Enter Part Time Employee Details"+"\n"+"================================"+"\n");
ob1.display();
ob.calculatepay();
ob.display();
}
}
}
答案 0 :(得分:0)
你的问题似乎就是这个部分:
void calculatepay() {
pension = ;
}
(正如编译器告诉你的那样)
除此之外,我们不在这里,解决你的作业