亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

格式標志轉換不匹配異常

格式標志轉換不匹配異常

夢里花落0921 2021-10-13 12:42:41
編寫一個程序,輸入三件物品的名稱、數量和價格。名稱可能包含空格。輸出稅率為 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;    }}
查看完整描述

2 回答

?
慕無忌1623718

TA貢獻1744條經驗 獲得超4個贊

你需要用另一個 % 來逃避你的 %

System.out.printf("8.265%% Sales tax %.2f\n        ", tax);


查看完整回答
反對 回復 2021-10-13
  • 2 回答
  • 0 關注
  • 142 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號