當前位置:編程學習大全網 - 編程語言 - 壹道java編程題 幫忙作下

壹道java編程題 幫忙作下

import javax.swing.JOptionPane;

class Massager

{

private int pay;

Massager(int pay,int num)

{

this.pay=pay*num;

}

int getPay()

{

return pay;

}

}

class Worker1

{

private int pay;

Worker1(int pay,int time,int num)

{

this.pay=(pay*time)*num;

}

int getPay()

{

return pay;

}

}

class Worker2

{

private int pay;

Worker2(int pay,int time,int num)

{

this.pay=num*(pay*time);

}

int getPay()

{

return pay;

}

}

class Saller

{

private int pay;

Saller(int pay,int time,int num)

{

this.pay=num*(int)(pay+time*0.2);

}

int getPay()

{

return pay;

}

}

public class Salary

{

public static void main(String[] args)

{

String moneytemp,numtemp,timetemp;

int money,num,time,total;

moneytemp=JOptionPane.showInputDialog("輸入每個管理工人月工資:");

numtemp=JOptionPane.showInputDialog("輸入管理工人人數:");

money=Integer.parseInt(moneytemp);

num=Integer.parseInt(numtemp);

Massager massager=new Massager(money,num);

moneytemp=JOptionPane.showInputDialog("輸入計件工人每造壹件東西的工資:");

timetemp=JOptionPane.showInputDialog("輸入每個計件工人制造東西的件數:");

numtemp=JOptionPane.showInputDialog("輸入計件工人人數:");

money=Integer.parseInt(moneytemp);

time=Integer.parseInt(timetemp);

num=Integer.parseInt(numtemp);

Worker1 worker1=new Worker1(money,time,num);

moneytemp=JOptionPane.showInputDialog("輸入計時工人每工作壹小時的工資:");

timetemp=JOptionPane.showInputDialog("輸入計時工人的工作總時間:");

numtemp=JOptionPane.showInputDialog("輸入計時工人人數:");

money=Integer.parseInt(moneytemp);

time=Integer.parseInt(timetemp);

num=Integer.parseInt(numtemp);

Worker2 worker2=new Worker2(money,time,num);

moneytemp=JOptionPane.showInputDialog("輸入銷售人員的基本工資:");

timetemp=JOptionPane.showInputDialog("輸入銷售人員的銷售業績:");

numtemp=JOptionPane.showInputDialog("輸入銷售人員人數:");

money=Integer.parseInt(moneytemp);

time=Integer.parseInt(timetemp);

num=Integer.parseInt(numtemp);

Saller saller=new Saller(money,time,num);

total=massager.getPay()+worker1.getPay()+worker2.getPay()+saller.getPay();

JOptionPane.showMessageDialog(null,"工廠工人的總工資:"+total);

}

}

  • 上一篇:腳本語言的應用和發展
  • 下一篇:輻射4-身形類MOD原理及結構科普性教學
  • copyright 2024編程學習大全網