Newer
Older
Java / practice / HowTallAreYou.java
import java.io. *;

public class HowTallAreYou {
  public static void main(String[] args){
  System.out.println("あなたの名前を入力してね");
  BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  try{
    String line = reader.readLine();
    System.out.println(line + "さん。こんにちは!");
    System.out.println("あなたの身長は何cmですか?(小数点まで入力してね)");
    line = reader.readLine();
    double height = Double.parseDouble(line);
    System.out.println("ほー!" + height + "cmですか!");
    int roughHeight = (int)height;
    System.out.println("ざっくりいうと" + (roughHeight) + "cmですね。");
  }catch (IOException e){
    System.out.println(e);
    }catch (NumberFormatException e){
      System.out.println("身長が正しくありません。");
    }
  }
}