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

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

為什么 planATotalPrice 沒有執行?

為什么 planATotalPrice 沒有執行?

斯蒂芬大帝 2021-10-28 09:31:22
import java.util.Scanner;//Needed for the Scanner class/** * 程序要求用戶輸入客戶購買的包裹的字母 (A,B,C) * 和使用的小時數。* 然后程序將計算客戶的每月賬單。* 套餐 A:每月 9.95 美元,包括 10 小時的互聯網服務。額外的小時數為每小時 2 美元。* 套餐 B:每月 13.95 美元,包括 20 小時的互聯網服務。額外的小時數為每小時 1 美元。* 套餐 AC:每月 19.95 美元,提供無限上網服務。* * 程序計算并顯示 A 套餐客戶在 * 購買套餐 B 或 C 時可節省的金額,以及套餐 B 客戶在 * 購買 C 時可節省的金額。 */public class InternetSavingsCh3 { public static void main(String[] args) // main 方法開始執行 Java 應用程序 { String input; // 保存用戶的輸入  double planAFixedPrice = 9.95;  double planBFixedPrice = 13.95;  double planCFixedPrice = 19.95; //  to hold the final monthly bill  double planAIncludedHours = 10.00; // total hours for interner plan  double plaBIncludedHours = 20.00; // total hours for interner plan  double planCIncludedHours = 0.0; // total hours for interner plan  double planAExtraHours,planBExtraHours, planCExtraHours;  double planAPricePerExtraHour = 2.0;  //  to hold the amount of charged for additional hours of internet use  double planBPricePerExtraHour = 1.0;   //  to hold the amount of charged for additional hours of internet use  double planCPricePerExtraHour = 0.0; //  to hold the amount of charged for additional hours of internet use  double planASavingsOnPlanB, planASavingsOnPlanC, planBSavingsOnPlanC;//  to hold the amount of savings per package  double planATotalPrice, planBTotalPrice, planCTotalPrice;  double totalHours; // to hold the total hours the Internet was used   Scanner keyboard = new Scanner(System.in); //create an object to read input from the standard input channel System.in (typically, the keyboard)  System.out.println(" Enter the letter of the Internet package you have purchased A,B,or C: "); // prompt the user for the internet package  input = keyboard.nextLine();  char packageInternet = input.charAt(0); // Internet package selected by the user  System.out.println(" Enter the total number of hours you used the Internet this month: "); //display instructions  totalHours = keyboard.nextDouble();
查看完整描述

2 回答

?
蕪湖不蕪

TA貢獻1796條經驗 獲得超7個贊

你之所以得到這個,是因為你已經聲明了變量 2 次并且范圍重疊......在這種情況下你聲明了一次:

    double planASavingsOnPlanB, planASavingsOnPlanC, planBSavingOnPlanC;//  to hold the amount of savings per package

      double planASavingsOnPlanB = planATotalPrice - planBFixedPrice; //compute the amount saved if purchasing plan B instead of plan A

基本上計算機不知道它會/應該使用哪一個。


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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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