PROGRAM Multiplication_Table
!---------------------------------------------------------------------------------
!	Program to calculate and display a list of products of two numbers.
!	Variables used are:
!		M, N	 				: the two numbers being multiplied
!		PROD				: their product
!		Last_M, Last_N	: the last values of M and N
!
!	Input		: Last_M and Last_M, the largest numbers to be multiplied
!	Output	: List of products M * N
!---------------------------------------------------------------------------------

	IMPLICIT NONE
	INTEGER :: M, N, Last_M, Last_N, Product
	
	PRINT *, "Enter the last values of the two numbers :"
	READ *, Last_M, Last_N
	PRINT *, "M   N   M*N"
	PRINT *, "============"
	
	DO M = 1, Last_M
		DO N = 1, Last_N
			Product = M * N
			PRINT *, M, "   ", N, "   ", Product
		END DO
	END DO
	
	pause
END PROGRAM Multiplication_Table




 
 

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

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.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




PROGRAM Half_Adder
!---------------------------------------------------------------------------------
!	Program to calculate the outputs from a logical circuit that
!	Represents a binary half-adder. Variables used are:
!		A, B				: the two logical inputs to the circuit
!		Sum, Carry	: the two logical outputs
!
!	Input		: The two logical inputs A and B
!	Output	: The two logical outputs Sum and Carry, which represent the
!				sum and carry that result when the input values are added
!---------------------------------------------------------------------------------

	IMPLICIT NONE
	LOGICAL :: A, B, Sum, Carry
	
	PRINT *, "Enter logical inputs A and B:"
	READ *, A, B
	Sum = (A .OR. B) .AND. .NOT. (A .AND. B)
	Carry = A .AND. B
	PRINT *, "Carry, Sum =", Carry, Sum
	
	pause
End PROGRAM Half_Adder




 
 

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

Program 4.1. 곱셈표의 출력  (0) 2014.04.27
Program 3.4. 오염지수 3  (0) 2014.04.06
Program 3.3. 오염지수 2  (0) 2014.04.06
Program 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
PROGRAM Pollition_3
!---------------------------------------------------------------------------------
!	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
!		LowCutoff, HighCutoff			: cutoff values that distinguish
!												between good/fair, and fair/poor
!												conditions, respectively
!		Index								: the integer average of the pollution levels
!
!	Input			: The three pollution levels and the cutoff value
!	Constant	: The two cutoff values
!	Output		: The pollution index and a "good condition" message if
!					this index is less than LowCcutoff, a "fair condition"
!					message if it is between LowCutoff and HighCutoff,
!					and a "poor condition" message otherwise
!---------------------------------------------------------------------------------

	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 (parts per million):"
	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 an appropriate
	! air-uality message
	SELECT CASE ( Index)
		CASE (:LowCutoff - 1)
			PRINT *, "Good condition"
		CASE (LowCutoff : HighCutoff - 1)
			PRINT *, "Fari condition"
		CASE (HighCutoff)
			PRINT *, Poor condition"
	END SELECT
	
	pause
End PROGRAM Pollition_3




 
 

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

Program 4.1. 곱셈표의 출력  (0) 2014.04.27
Program 3.5. 이진 반가수기  (0) 2014.04.06
Program 3.3. 오염지수 2  (0) 2014.04.06
Program 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
PROGRAM Pollition_2
!---------------------------------------------------------------------------------
!	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
!		LowCutoff, HighCutoff			: cutoff values that distinguish
!												between good/fair, and fair/poor
!												conditions, respectively
!		Index								: the integer average of the pollution levels
!
!	Input			: The three pollution levels and the cutoff value
!	Constant	: The two cutoff values
!	Output		: The pollution index and a "good condition" message if
!					this index is less than LowCcutoff, a "fair condition"
!					message if it is between LowCutoff and HighCutoff,
!					and a "poor condition" message otherwise
!---------------------------------------------------------------------------------

	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 (parts per million):"
	READ *, Level_1, Level_2, Level_3
	
	! Classify the pollution index and display an appropriate
	! air-quality message
	IF (Index < LowCutoff) THEN
		PRINT *, "Good condition"
	ELSE IF (Index < HighCutoff) THEN
		PRINT *, "Poor condition"
	END IF
	
	pause
End PROGRAM Pollition_2




 
 

'노트 > 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.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