結果 : java's scanner hasnext () method is helpful for this problem