1program sample
2 implicit none
3
4 character(len=32) :: c
5 integer :: i, score
6
7 ! 整数を読み込む
8 write(*, *) 'Input integer : '
9 read(*, *) i
10
11 ! 整数の値で場合分け
12 select case(i)
13 case(0) ! i == 0 のとき
14 write(*, *) 'your input was zero'
15 case(1) ! i == 1 のとき
16 write(*, *) 'your input was one'
17 case(2) ! i == 2 のとき
18 write(*, *) 'your input was two'
19 case(3) ! i == 3 のとき
20 write(*, *) 'your input was three'
21 case default ! 上記以外全て
22 write(*, *) 'your input was too large'
23 endselect
24
25 ! 点数を読み込む
26 write(*, *) ''
27 write(*, *) 'Input score : '
28 read(*, *) score
29
30 select case(score)
31 case(0) ! 0点
32 write(*, *) 'zero'
33 case(1:29) ! 1-29点
34 write(*, *) 'poor'
35 case(30:59) ! 30-59点
36 write(*, *) 'fair'
37 case(60:89) ! 60-89点
38 write(*, *) 'good'
39 case(90:100) ! 90-100点
40 write(*, *) 'excellent'
41 case default ! それ以外
42 write(*, *) 'invalid input'
43 endselect
44
45 ! 文字列を読み込む
46 write(*, *) ''
47 write(*, *) 'Input language : '
48 read(*, *) c
49
50 ! 文字列の値で場合分け
51 select case(c)
52 case('c', 'c++', 'fortran')
53 write(*, *) 'compiled language'
54 case('python', 'perl', 'ruby')
55 write(*, *) 'script language'
56 case('english', 'japanese', 'french', 'chinese')
57 write(*, *) 'natural language'
58 case default
59 write(*, *) 'others'
60 endselect
61
62 stop
63endprogram sample