📄 salarylist.java
字号:
/**
* @(#)SalaryList.java
*
*
* @author
* @version 1.00 2009/3/3
*/
//打印员工的工资单
import javax.swing.JOptionPane;
public class SalaryList {
/**
* Creates a new instance of <code>SalaryList</code>.
*/
public SalaryList() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
//Input employee's full name
String StringFullName=JOptionPane.showInputDialog(null,"Enter employee's full name:",
"Exercise2_13 Input",JOptionPane.QUESTION_MESSAGE);
//Input number of hours worked in a week
String StringNumberOfHours=JOptionPane.showInputDialog(null,
"Enter number of hours worked in a week:","Exercise2_13 Input",JOptionPane.QUESTION_MESSAGE);
//Convert string into double.
double DoubleNumberOfHours=Double.parseDouble(StringNumberOfHours);
//Input hourly pay rate
String StringHourlyPayRate=JOptionPane.showInputDialog(null,
"Enter hourly pay rate:","Exercise2_13 Input",JOptionPane.QUESTION_MESSAGE);
//Convert string into double
double DoubleHourlyPayRate=Double.parseDouble(StringHourlyPayRate);
//Input federal tax withholding rate
String StringFederalTaxRate=JOptionPane.showInputDialog(null,
"Enter federal tax withholding rate:","Exercise2_13 Input",JOptionPane.QUESTION_MESSAGE);
//Convert string into double
double DoubleFederalTaxRate=Double.parseDouble(StringFederalTaxRate);
//Input state tax withholding rate
String StringStateTaxRate=JOptionPane.showInputDialog(null,
"Enter state rate withholding rate:","Exercise2_13 Input",JOptionPane.QUESTION_MESSAGE);
double DoubleStateTaxRate=Double.parseDouble(StringStateTaxRate);
//Calculate grass pay
double DoubleGrassPay=DoubleHourlyPayRate*DoubleNumberOfHours;
//Calculate Deductions
double DoubleFederalWithholding=DoubleGrassPay*DoubleFederalTaxRate;
double DoubleStateWithholding=DoubleGrassPay*DoubleStateTaxRate;
double DoubleTtotalDeductions=DoubleFederalWithholding+DoubleStateWithholding;
//Calculate Deductions
double DoubleNetPay=DoubleGrassPay-DoubleTtotalDeductions;
//Salary List
String OutPut="Employee Name:"+StringFullName+"\n\n";
OutPut+="Hours Worked:"+StringNumberOfHours+"\n";
OutPut+="Pay Rate: $"+StringHourlyPayRate+"\n";
OutPut+="Grass Pay: $"+DoubleGrassPay+"\n";
OutPut+="Deductions:\n";
OutPut+=" Federal Withholding("+(DoubleFederalTaxRate*100)+"%): $"+DoubleFederalWithholding+"\n";
OutPut+=" State Withholding("+(DoubleStateTaxRate*100)+"%): $"+DoubleStateWithholding+"\n";
OutPut+=" Total Deductions: $"+DoubleTtotalDeductions+"\n";
OutPut+="Net Pay: $"+DoubleNetPay+"\n";
//Output Salary List
JOptionPane.showMessageDialog(null,OutPut,"Exercise2_13 Output",JOptionPane.INFORMATION_MESSAGE);
return;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -