java吧 关注:1,269,337贴子:12,776,091
  • 1回复贴,共1

【第二次编JAVAT^T求解~】错误: 找不到或无法加载主类 e2_11_1.e

只看楼主收藏回复

package e2_11_1;
import javax.swing.JOptionPane;
public class e2_11_1 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String name = JOptionPane.showInputDialog("Enter employeek\'s name:");
String hoursWorkedString = JOptionPane.showInputDialog("Enter number of hours worked in a week:");
double hoursWorked = Double.parseDouble(hoursWorkedString);
String hourlyPayRateString = JOptionPane.showInputDialog("Enter hourly pay rate:");
double hourlyPayRate = Double.parseDouble(hourlyPayRateString);
String federalTaxRateString = JOptionPane.showInputDialog("Enter federal tax withholding rate:");
double federalTaxRate = Double.parseDouble(federalTaxRateString);
String stateTaxRateString = JOptionPane.showInputDialog("Enter state tax withholding rate:");
double stateTaxRate = Double.parseDouble(stateTaxRateString);
hoursWorked = (int)(hoursWorked * 10) / 10.0;
hourlyPayRate = (int)(hourlyPayRate * 100) / 100.00;
double grossPay = (int)(hoursWorked * hourlyPayRate * 100) / 100.00;
double federalWithholding = (int)(federalTaxRate * grossPay * 100) / 100.00;
double stateWithholding = (int)(stateTaxRate * grossPay * 100) / 100.00;
double totalDeduction = federalWithholding + stateWithholding;
String output = "Employee Name:" + name + "\nHours Worked:" + hoursWorked + "\nPay Rate:$" + hourlyPayRate + "\nGross Pay:$" + grossPay + "\nDeductions:" + "\n Federal Withholding(20.0%):$" + federalWithholding + "\n State Withholding(9.0%):$" + stateWithholding + "\n Total Deduction:$" + totalDeduction + "\nNet Pay: $" + (grossPay - totalDeduction);
JOptionPane.showMessageDialog(null, output);
}
}


1楼2015-03-25 23:52回复
    不用对话框 用在控制台输入就是对的
    不知道这么一改哪里错了~
    唔 就是《Java语言程序设计基础篇》 编程练习2.11上的……
    不太会啊T^T~


    2楼2015-03-25 23:54
    回复