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

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

我的代碼中出現(xiàn)運行時錯誤。當(dāng)我輸入字母時,布爾有效值變?yōu)閠rue

我的代碼中出現(xiàn)運行時錯誤。當(dāng)我輸入字母時,布爾有效值變?yōu)閠rue

溫溫醬 2021-05-07 18:14:06
該代碼將輸入密碼,并檢查密碼是否包含字母和數(shù)字。如果沒有密碼,則兩個注冊都將繼續(xù)。當(dāng)我輸入字母和數(shù)字時,寄存器是完整的;當(dāng)我輸入數(shù)字時,只有寄存器會繼續(xù);當(dāng)我輸入字母時,只有寄存器是完整的而不包含數(shù)字。import java.io.*;public class Sample {static BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));public static void main (String[] args)throws Exception {    boolean valid = false;    boolean alphaCheck = false;    boolean numCheck = false;    char[] alpha = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};    char[] num = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'};    do {        System.out.println("Password must contain Letters and Numbers Only. (abc../ABC.., 123..)");        System.out.println("Special Characters are not Allowed.");        System.out.print("Register Password: ");        String password = dataIn.readLine();        char[] passwordToArray = password.toUpperCase().toCharArray();        // Check if password contains numbers        for(char x: passwordToArray){            for(char y: num){                if(x==y){                    numCheck = true;                    break;                }            }        }        // Check if password contains Letters        for(char x: passwordToArray){            for(char y: alpha){                if(x==y){                    alphaCheck = true;                    break;                }            }        }        if(!numCheck){            System.out.println("No Numbers Found.");        }        if(!alphaCheck){            System.out.println("No Letters Found.");        }        // Check if password contains both Alphabets and Numbers        // if false Continue Register        if((numCheck)&&(alphaCheck)){            System.out.println("Register Complete");            valid = true;        }else{            System.out.println("Register Failed. Please Try again");        }    }while (!valid) ;}}
查看完整描述

2 回答

  • 2 回答
  • 0 關(guān)注
  • 173 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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