算工资

import javax.swing.JOptionPane;
public class Salary {
    public static void main(String[] args){
        String name = JOptionPane.showInputDialog(null,"请输入姓名:");
        String input = JOptionPane.showInputDialog(null,"请输入每周工作时间:");
        String input1 = JOptionPane.showInputDialog(null,"请输入每小时工资:");
        String input2 = JOptionPane.showInputDialog(null,"请输入联邦所得税税率:");
        String input3 = JOptionPane.showInputDialog(null,"请输入州所得税税率:");
        double hours = Double.parseDouble(input);
        double rate = Double.parseDouble(input1);
        double federal = Double.parseDouble(input2);
        double state = Double.parseDouble(input3);
        System.out.println("Employee Name:" + name);
        System.out.println("Hours Worked:" + hours);
        System.out.println("Pay Rate:" + hours);
        System.out.println("Gross Pay:" + hours * rate);
        System.out.println("Deductions:");
        System.out.println("Federal Withholding:" + hours * rate * federal);
        System.out.println("State Witholding:" + hours * rate * state);
        System.out.println("Total Deduction:" + (hours * rate * federal + hours * rate * state));
        System.out.println("Net Pay:" + (hours * rate - (hours * rate * federal + hours * rate * state)));
    }

}

输入员工姓名,每周工作时间,每小时工资,联邦所得税税率,州所得税税率。输出员工工资单。

员工工资等于每周时间*每小时就工资-联邦交的税-州交的税。

posted @ 2014-08-06 16:06  Amoxicil  阅读(149)  评论(0编辑  收藏  举报