PROGRAM Pollition
!---------------------------------------------------------------------------------
!	Program that reads 3 pollution levels, calculates a pollution
!	Index as their integer average, and then displays an appropriate
!	air-quality message. Identifiers used are:
!		Level_1, Level_2, Level_3	: The three pollution levels
!		Cutoff								: a cutoff value that distinguishes between hazardous
!												and safe conditions (parameter)
!		Index								: The three pollution levels and the cutoff value
!	Input			: The three pollution levels and the cutoff value
!	Constant	: The cutoff value (parts per million)
!	Output		: The pollution index and a "safe condition" message if
!					this index is less than the cutoff value, otherwise a
!					"hazardous condition" message
!---------------------------------------------------------------------------------

	IMPLICIT NONE
	INTEGER :: Level_1, Level_2, Level_3, Index
	INTEGER, PARAMETER :: Cutoff = 50
	
	! Get the 3 pollution readings
	PRINT *, "Enter 3 pollution readings (parts per million):"
	READ *, Level_1, Level_2, Level_3
	
	! Calculate the pollution index
	Index = (Level_1 + Level_2 + Level_3) / 3
	
	! Check if the pollution index is less than the cutoff and
	! display an appropriate air-quality message
	IF (Index < Cutoff) THEN
		PRINT *, "Safe condition"
	ELSE
		PRINT *, "Hazardous condition"
	END IF
	
	pause
End PROGRAM Pollition




 
 

'노트 > Fortran 연습' 카테고리의 다른 글

Program 4.1. 곱셈표의 출력  (0) 2014.04.27
Program 3.5. 이진 반가수기  (0) 2014.04.06
Program 3.4. 오염지수 3  (0) 2014.04.06
Program 3.3. 오염지수 2  (0) 2014.04.06
Program 3.1. 이차 방정식  (0) 2014.04.06
Program 2.Exercise6.2. 온도 변환 (2nd Version)  (0) 2014.03.23
Program 2.Exercise6.1. 온도 변환 (1st Version)  (0) 2014.03.23
Program 2.Exercise5  (0) 2014.03.23
Program 2.1. 발사체 문제  (0) 2014.03.22
Program 1.Exercise10  (0) 2014.03.22

+ Recent posts