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

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

如何在輸出中獲取輸入詞?初學Java

如何在輸出中獲取輸入詞?初學Java

元芳怎么了 2021-09-29 13:39:51
我試圖在我的輸出中找到出發地點,但我對如何去做感到困惑。我是否必須在頂部的 String 方法中聲明它?    int seconds1;    int seconds2;    int minutes;    int hours;    Scanner sc = new Scanner(System.in);    System.out.println("Enter departure city: ");    String departure = sc.nextLine();    System.out.println("Enter arrival city ");    String arrival = sc.nextLine();    System.out.println("Enter time (in seconds) it takes to travel between: ");    seconds1 = sc.nextInt();    hours = (seconds1 % 86400) / 3600;    minutes = ((seconds1 % 86400) % 3600) / 60;    seconds2 = ((seconds1 % 86400) % 3600) % 60;    // I am trying to get this to say "The time between + departure + and + arrival+is"    System.out.println("The time to travel  between and  is ");     System.out.println(hours + " : " + minutes + " : " + seconds2);  }}
查看完整描述

3 回答

?
米琪卡哇伊

TA貢獻1998條經驗 獲得超6個贊

您可以指定departurearrival變量,System.out.println()如下面的代碼所示:

System.out.println("The time to travel  between"+departure +" and"+arrival +"  is ");


查看完整回答
反對 回復 2021-09-29
?
揚帆大魚

TA貢獻1799條經驗 獲得超9個贊

你會有這個:

System.out.println("The time to travel between " + departure + " and " + arrival + " is ");



查看完整回答
反對 回復 2021-09-29
  • 3 回答
  • 0 關注
  • 181 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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