📄 computesalestax.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 + -