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

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

如何修復(fù)while循環(huán)錯(cuò)誤登錄注銷(xiāo)系統(tǒng)(無(wú)數(shù)據(jù)庫(kù))(還有關(guān)于會(huì)話時(shí)間的代碼)?

如何修復(fù)while循環(huán)錯(cuò)誤登錄注銷(xiāo)系統(tǒng)(無(wú)數(shù)據(jù)庫(kù))(還有關(guān)于會(huì)話時(shí)間的代碼)?

喵喵時(shí)光機(jī) 2022-06-04 10:43:12
我使用為我的學(xué)校作業(yè)提供的唯一用戶名創(chuàng)建了一個(gè)基本的登錄和注銷(xiāo)系統(tǒng)(無(wú)數(shù)據(jù)庫(kù)),但我在 while 循環(huán)和會(huì)話時(shí)間方面遇到了問(wèn)題。我嘗試將一組代碼復(fù)制并粘貼到此主代碼的不同部分,以便獲得預(yù)期的結(jié)果,但結(jié)果有點(diǎn)錯(cuò)誤。我試圖在互聯(lián)網(wǎng)上搜索有關(guān)會(huì)話時(shí)間的信息,但一無(wú)所獲。  while (login =  true){      try {          System.out.println("Enter your name:");          String name = cue.nextLine();          System.out.println("--------------------");          System.out.println("");          System.out.println("Date and Time of Login:");          System.out.println(dtf.format(now));          System.out.println("");          System.out.println("--------------------");          System.out.println();          System.out.println("Enter your name to log out:");          String logout = cue.nextLine();          System.out.println("");          if (logout.equals(name)){              System.out.println("--------------------");              System.out.println("");              System.out.println("Date and Time of Logout:");              System.out.println(dtf.format(now));              System.out.println("Session Time:");              /*can you also please tell me what code to tell the gap between the               login time and log out time?*/              System.out.println("");              System.out.println("--------------------");              login = false;            } else {                login = true;            }        } catch (Exception e){          cue.nextLine();      } finally{          System.out.println("Do you want to register again? 0 for yes and 1 for no");          int no = cue.nextInt();          if (no==0) {              login = true;          } else if (no==1) {                System.exit(1);          } else {              System.out.println("1 or 0 only!");          }         }}這必須是預(yù)期的輸出:如果名稱(chēng)正確:Enter your name:nmae--------------------Date and Time of login:2019/02/03 16:38:46--------------------Enter your name to log out:nmae--------------------
查看完整描述

2 回答

?
慕桂英4014372

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

要獲得不同的 beetwen 登錄時(shí)間和注銷(xiāo)時(shí)間,您可以使用Durationjava8 中的類(lèi):


loginTime = LocalDateTime.now();

...

logoutTime = LocalDateTime.now();


Duration.between(loginTime, logoutTime).getSeconds();


查看完整回答
反對(duì) 回復(fù) 2022-06-04
?
人到中年有點(diǎn)甜

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

您正在返回錯(cuò)誤級(jí)別 1,這是程序終止向操作系統(tǒng)返回錯(cuò)誤的方式。我無(wú)法測(cè)試是因?yàn)槲也皇褂?Windows,但您可以嘗試System.exit(1)System.exit(0).



查看完整回答
反對(duì) 回復(fù) 2022-06-04
  • 2 回答
  • 0 關(guān)注
  • 111 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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