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

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

if Scanner Boolean statement with 2 nextInt()

if Scanner Boolean statement with 2 nextInt()

郎朗坤 2022-05-12 17:18:40
我寫了這段代碼,但是當(dāng)我的密碼正確時(shí)我有問題。請指導(dǎo)我。我是 Java 編碼的新手import java.util.Scanner;public class PasswordProjectQ {    private static Scanner passwordInput;    public static void main(String[] args) {        passwordInput = new Scanner(System.in);        int builtInPassword = 3720118;        System.out.println("Please enter your password:(just integer)");        if(passwordInput.hasNextInt() && passwordInput.nextInt() != builtInPassword) {            System.out.println("You entered the right format \nbut the password is WRONG!");        }else if(passwordInput.hasNextInt() && passwordInput.nextInt() == builtInPassword) {            System.out.println("Thanks,your password is correct");        }else {            System.out.println("WRONG format!");        }    }}
查看完整描述

1 回答

?
慕碼人8056858

TA貢獻(xiàn)1803條經(jīng)驗(yàn) 獲得超6個(gè)贊

您必須調(diào)用一次才能獲取密碼,如下所示hasNextInt():passwordInput.nextInt()


if (passwordInput.hasNextInt()) {

    if (passwordInput.nextInt() != builtInPassword) {

        System.out.println("You entered the right format \nbut the password is WRONG!");

    } else {

        System.out.println("Thanks,your password is correct");

    }

} else {

    System.out.println("WRONG format!");

}


查看完整回答
反對 回復(fù) 2022-05-12
  • 1 回答
  • 0 關(guān)注
  • 106 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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