⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exercise2_15.java

📁 java程序设计 机械工业出版社 书籍代码
💻 JAVA
字号:
import javax.swing.JOptionPane;public class Exercise2_15 {  public static void main(String args[]) {    // Obtain input    System.out.print("Enter employee's full name: ");    String name = MyInput.readString();        System.out.print("Enter number of hours worked in a week: ");    double hours = MyInput.readDouble();             System.out.print("Enter hourly pay rate: ");    double payRate = MyInput.readDouble();        System.out.print("Enter federal tax withholding rate: ");    double fedTaxWithholdingRate = MyInput.readDouble();    System.out.print("Enter state tax withholding rate: ");    double stateTaxWithholdingRate = MyInput.readDouble();    double grossPay = hours * payRate;    double fedTaxWithholding = grossPay * fedTaxWithholdingRate;    double stateTaxWithholding = grossPay * stateTaxWithholdingRate;    double totalDeduction = fedTaxWithholding + stateTaxWithholding;    double netPay = grossPay - totalDeduction;    // Obtain output    String out = "Employee Name: " + name + "\n\n";    out += "Hours Worked:" + "  " + hours + '\n';    out += "Pay Rate:" + "  $" + payRate + '\n';    out += "Gross Pay:" + "  $" + grossPay + '\n';    out += "Deductions:\n";    out += "  Federal Withholding (" + fedTaxWithholdingRate * 100 + "%):" + "  $" + (int)(fedTaxWithholding * 100) / 100.0 + '\n';    out += "  State Withholding (" + stateTaxWithholdingRate * 100 + "%):" + "  $" + (int)(stateTaxWithholding * 100) / 100.0 + '\n';    out += "  Total Deduction:" + "  $" + (int)(totalDeduction * 100) / 100.0 + '\n';    out += "Net Pay:" + "   $" + (int)(netPay * 100) / 100.0;     System.out.print(out);  }}

⌨️ 快捷键说明

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