📄 ex2_13.java
字号:
//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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -