728x90
반응형
1. 오염지수 구하기 - IF 문
PROGRAM pollution
IMPLICIT NONE
INTEGER :: level_1, level_2, level_3, index
INTEGER, PARAMETER :: cutoff = 50
! get the 3 pollution readings
PRINT *, "Enter 3 pollution readings (unit: ppm) :"
READ *, level_1, level_2, level_3
index = (level_1 + level_2 + level_3)/3
IF (index < cutoff) THEN
PRINT *, "SAFE"
ELSE
PRINT *, "HAZARDOUS"
END IF
pause
end program pollution
2. 오염지수 구하기 - IF-ELSE 문
program pollution
implicit none
integer :: level_1, level_2, level_3, index
integer, parameter :: lowcutoff = 25, highcutoff = 50
! get the 3 pollution readings
print *, "Enter 3 pollution readings (unit: ppm) :"
read *, level_1, level_2, level_3
! Calculate the pollution index
index = (level_1 + level_2 + level_3)/3
! classify the pollution index and display air-quality conditions
if (index < lowcutoff) then
print *, "GOOD"
else if (index < highcutoff) then
print *, "FAIR"
else
print *, "POOR"
end if
pause
end program pollution
과제
화씨와 섭씨를 구분해 변환하는 하나의 코드 작성
728x90
반응형