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

📄 computesalestax.java

📁 《A first book of java》by Gary J.Bronson 北大出版社
💻 JAVA
字号:
import java.text.*; // needed for formatting
import javax.swing.*;
public class ComputeSalesTax
{  
  public static void main (String[] args) 
  {    
    final double SALESTAX = 0.05;    
    String input, output;
    double amount, taxes, total;
    DecimalFormat num = new DecimalFormat("#.00");
    
    input = JOptionPane.showInputDialog("Enter the amount purchased:");
    amount = Double.parseDouble(input);    
    taxes = SALESTAX * amount;
    total = amount + taxes;
    output = "The sales tax is $" + num.format(taxes);
    output += "\nThe total bill is $" + num.format(total);
    JOptionPane.showMessageDialog(null, 
            output, "Program 3-16",
           JOptionPane.INFORMATION_MESSAGE);
      
    System.exit(0);
  }
}

⌨️ 快捷键说明

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