我已经坚持了一段时间,一个计算 20 名工人平均工资的 Java 程序,这是我到目前为止想出的。………………………………………………………………………………………………………………………………………………………… ………………………………………………………………………………………………………………………………………………………… ………………………………………………………………………………………………………………………………………………………… ......
import java.util.Scanner;
class Employee
{
int age;
String name, address, gender;
Scanner get = new Scanner(System.in);
Employee()
{
System.out.println("Enter Name of the Employee:");
name = get.nextLine();
System.out.println("Enter Gender of the Employee:");
gender = get.nextLine();
System.out.println("Enter Address of the Employee:");
address = get.nextLine();
System.out.println("Enter Age:");
age = get.nextInt();
}
void display()
{
System.out.println("Employee Name: "+name);
System.out.println("Age: "+age);
System.out.println("Gender: "+gender);
System.out.println("Address: "+address);
}
}
class fullTimeEmployees extends Employee
{
float salary;
int des;
fullTimeEmployee()
{
System.out.println("Enter Designation:");
des = 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: "+des);
}
}
class partTimeEmployees extends Employee
{
int workinghrs, rate;
partTimeEmployees()
{
System.out.println("Enter Number of Working Hours:");
workinghrs = get.nextInt();
}
void calculatepay()
{
rate = 8 * workinghrs;
}
慕田峪4524236
蛊毒传说
相关分类