computesalestax.java
来自「《A first book of java》by Gary J.Bronson 」· Java 代码 · 共 24 行
JAVA
24 行
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 + =
减小字号Ctrl + -
显示快捷键?