実験課題3

Exercise 3(課題3) See the section 1.6.1. "About Selection". Then, first, modify the Fig. 59 program to judge the input data from keyboard by creatintg Java project chapter1kadai3. Second, show the source code and the execution result as the screenshot. To convert the string object to int value, use parseInt method in Integer class as follows.

String str = "42";
int x = Integer.parseInt(str); // 文字列型オブジェクトをint型の値に変換する。
System.out.println(x * x); // 1764と表示される。
Figure:Example of the conversion from String type object to int type value

(1.6.1.節をよく読み、プロジェクト名chapter1kadai3のJavaアプリケーションプロジェクトを作成して、図59のプログラムを標準入力から受け取ったデータについて判断するように変更しなさい。そしてソースコードと実行結果を示すこと。なお、入力から取得した文字列型オブジェクトをint型の値に変換するためには、次に示す、IntegerクラスのparseIntメソッドを使いなさい。)