编写一个程序,输入三件物品的名称、数量和价格。名称可能包含空格。输出税率为 6.25% 的票据。所有价格都应输出到小数点后两位。帐单格式为列式,名称为 30 个字符,数量为 10 个字符,价格为 10 个字符,总数为 10 个字符。示例输入和输出如下所示:import java.util.Scanner;public class ProjectLab { public static final double SALES_TAX = 8.625; public static void main(String[]args) { Scanner input = new Scanner(System.in); String item1, item2, item3; int quantity1, quantity2, quantity3; double price1, price2, price3; //Input for the first Item System.out.println("Input the name of item 1: "); item1 = input.nextLine(); System.out.println("Input quantity of item 1: "); quantity1 = input.nextInt(); System.out.println("Input price of item 1: "); price1 = input.nextDouble(); String junk = input.nextLine(); //Junk Line //Input for the second Item System.out.println("Input name of item 2: "); item2 = input.nextLine(); System.out.println("Input quantity of item 2: "); quantity2 = input.nextInt(); System.out.println("Input price of item 2: "); price2 = input.nextDouble(); String junk2 = input.nextLine(); //Junk line 2 //Input for the third item System.out.println("Input name of item 3: "); item3 = input.nextLine(); System.out.println("Input quantity of item 3: "); quantity3 = input.nextInt(); System.out.println("Input price of item 3: "); price3 = input.nextDouble(); double subtotal1 = price1 * quantity1; double subtotal2 = price2 * quantity2; }}
添加回答
举报
0/150
提交
取消