package com.swift;
import java.util.Scanner;
public class PurchaseTaxDecimalsTwo {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);//扫描工作台输入
double purchaseAmount=scan.nextDouble();//输入数值赋值 购买额变量
System.out.println(purchaseAmount);
double taxRate=0.06;//税率
double tax;
tax=purchaseAmount*taxRate;//税 多位小数
System.out.println(tax);
System.out.println((int)(tax*100));//乘100除100.0保留2位小数
System.out.println((int)(tax*100)/100.0);//不能除100
}
}
时间: 2024-10-11 05:05:37