ex2_13.java

来自「判断三角形」· Java 代码 · 共 29 行

JAVA
29
字号
//2.13(工资单)
import javax.swing.JOptionPane;
  public class Ex2_13{
  	public static void main (String[] args) {
       String fname,paybill;
       double hour,salary,ftax,stax;
       fname=JOptionPane.showInputDialog(null,"Enter employee's full name:","Ex2_13 Input",
       JOptionPane.QUESTION_MESSAGE);
       hour=Double.parseDouble(JOptionPane.showInputDialog(null,"Enter number of hours worked in a week:","Ex2_13 Input",
       JOptionPane.QUESTION_MESSAGE));
       salary=Double.parseDouble(JOptionPane.showInputDialog(null,"Enter hourly pay rate:","Ex2_13 Input",
       JOptionPane.QUESTION_MESSAGE));
       ftax=Double.parseDouble(JOptionPane.showInputDialog(null,"Enter federal tax withholding rate:","Ex2_13 Input",
       JOptionPane.QUESTION_MESSAGE));
       stax=Double.parseDouble(JOptionPane.showInputDialog(null,"Enter state tax withholding rate:","Ex2_13 Input",
       JOptionPane.QUESTION_MESSAGE));
       paybill="Employee Name:"+fname+"\n\n\n"+
       	"Hours Worked:"+hour+"\n"+
       	"Pay Rate:"+salary+"\n"+
       	"Gross Pay:"+salary*hour+"\n"+   //工资总额
       	"Deductions:"+"\n"+
       	" Federal Withholding:"+salary*hour*ftax+"\n"+
       	" State Withholding:"+salary*hour*stax+"\n"+
       	" Total Deduction:"+salary*hour*(ftax+stax)+"\n"+   //扣款总额
       	"Net Pay:"+salary*hour*(1-ftax-stax);  //实际工资
       	JOptionPane.showMessageDialog(null,paybill,"Ex2_13 Output",
       	JOptionPane.INFORMATION_MESSAGE);
}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?