//一个很简单的给员工加工资的代码?
//很简单,不过也用了我不少的时间
//这是我第一个JAVA程序
import javax.swing.*;
public class AdminHour
{
public static void main(String[] args)
{
Emplogee[] staff = new Emplogee[3];
String input = JOptionPane.showInputDialog
("how much money for A take");
int k = Integer.parseInt(input);
input = JOptionPane.showInputDialog
("how much money for B take");
int k1 = Integer.parseInt(input);
input = JOptionPane.showInputDialog
("how much money for C take");
int k2 = Integer.parseInt(input);
input = JOptionPane.showInputDialog
("How much add ");
double add = Integer.parseInt(input);
staff[0] = new Emplogee("A",k );
staff[1] = new Emplogee("B",k1);
staff[2] = new Emplogee("c",k2);
for(int i = 0;i < staff.length; i++)
staff[i].getAdd(add);
for(int i = 0;i < staff.length; i++)
{Emplogee e = staff[i];
System.out.println("name=" + e.getName() + "\nOmoney=" + e.getOmoney() + "\nNmoney=" + e.getNmoney());
}
}
}
class Emplogee
{
public Emplogee (String n ,double s)
{ name = n;
money = s;
}
public String getName()
{
return name;
}
public double getOmoney()
{
return money;
}
public double getNmoney()
{
return Hadd;
}
public void getAdd(double byPercent)
{
double raise = money * byPercent / 100;
Hadd = raise + money;
}
private String name;
private double money;
private double Hadd;
}
本文地址:http://com.8s8s.com/it/it33301.htm