calculatetaxes.java

来自「《A first book of java》by Gary J.Bronson 」· Java 代码 · 共 24 行

JAVA
24
字号
import javax.swing.*;
import java.text.*;  // needed for formatting
public class CalculateTaxes
{
  public static void main(String[] args)
  {
    double taxable, taxes;
    String s1;
    DecimalFormat df = new DecimalFormat(",###.00");
    s1 =JOptionPane.showInputDialog("Please type in the taxable income:");
    taxable = Double.parseDouble(s1);
     
    if (taxable <= 20000.0)
      taxes = 0.02 * taxable;
    else
      taxes = 0.025 * (taxable - 20000.0) + 400.0;
    JOptionPane.showMessageDialog(null, "Taxes are $" + df.format(taxes), 
                                "Program 4.1", 
                                JOptionPane.INFORMATION_MESSAGE);
    
    System.exit(0);  
  }
}

⌨️ 快捷键说明

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