第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

線程“main”中的異常 java.util.Input MismatchException

線程“main”中的異常 java.util.Input MismatchException

猛跑小豬 2023-10-13 16:24:43
我正在做班級的家庭作業(yè)。你得計算一下這個月的工資。每次我嘗試運(yùn)行它時,它都會不斷地說:我該如何解決這個問題?線程“main”中的異常 java.util.InputMismatchException在 java.util.Scanner.throwFor (Scanner.java:864)在 java.util.Scanner.next(Scanner.java:1485)在 java.util.Scanner.nextInt(Scanner.java:2117)在java.util.Scanner.nextInt(Scanner.java:2076)在 D2.main(D2.java:23)import java.util.Scanner;public class D2{    public static void main(String[] args)    {        Scanner sc = new Scanner(System.in);        int L1Cs = 80;        int L2Cs = 120;        int L3Cs = 160;        int L1Ct = 100;        int L2Ct = 140;        int L3Ct = 180;        int L1Csv = 100;        int L2Csv = 150;        int L3Csv = 200;        int BSalary = 3000;        int Stotal, Ttotal, SVtotal;        System.out.println("Please enter your name");        int name = sc.nextInt();        System.out.println("How many sedans have you sold this month");        int Sedans = sc.nextInt();        System.out.println("How many trucks have you sold this month");        int Trucks = sc.nextInt();        System.out.println("How many SUVs have you sold this month");        int SUVs = sc.nextInt();        if(Sedans <= 10)        {            Stotal = (L1Cs * Sedans);        }        else if (Sedans >= 11 && Sedans <=20)        {            Stotal = (L1Cs*10 +(Sedans - 10) * L2Cs);        }        else        {            Stotal = (L1Cs*10 +L1Cs *10 + (Sedans - 10) * L3Cs);        }        System.out.println("Your comission for the sedans is:" + Stotal);        if(Trucks <= 10)        {            Ttotal = (L1Cs * Trucks);        }        else if (Trucks >= 11 && Trucks <=20)        {            Ttotal = (L1Ct*10 + (Trucks - 10) * L2Ct);        }        else        {            Ttotal = (L1Ct*10 + L2Ct *10 + (Trucks - 10) * L3Ct);        }
查看完整描述

1 回答

?
守著一只汪

TA貢獻(xiàn)1872條經(jīng)驗 獲得超4個贊

它似乎失敗的提示是:

"Please enter your name"

如果您輸入的是您的姓名而不是整數(shù),這就是它拋出異常的原因。掃描儀將尋找一個整數(shù),但你的名字不是。您可能想要替換:

int name = sc.nextInt();

和:

String name = sc.next();

或類似于將名稱獲取為字符串的內(nèi)容。


查看完整回答
反對 回復(fù) 2023-10-13
  • 1 回答
  • 0 關(guān)注
  • 119 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號