C      Programmer: Zach Etzel
C      Course: CS 430
C      Date Due: September 13, 2007
C      Language: FORTRAN
C      Compiler used: FORCE2.08
C      Source Filename: ZachEtzelPA2.f
C      Executable Filename (if any) or None:
C      Professor: Elizabeth Adams


C     Purpose:  This Program queries the user for integer and  decimal
C               numbers and then converts them into Binary numbers.
C
C     Input:   One Integer, One Decimal
C     Output:  Original Integer, Original Decimal, Formatted Binary Numbers
C     Language information
C        DIMENSION indicates that the variable name(s) which follow are arrays
C        The number in parentheses indicates the size of the array
C        If the array is to be an integer array its name must begin with one of the letters I-N
C        Although the values to be read are real values, the format statement places the decimal points
C        READ is the input statement.
C        The 5 in the READ statement indicates the default input device
C        The 1X in the format descriptor means 1 blank space

C        This work complies with the JMU honor code

C      Input and variable assignment
C      There are two arrays for each type of number to be input
       DIMENSION INPUT(15)
       DIMENSION MINPUT(6)

C      ISIZE is the array size
C      Y is the input value for the Decimal Value
C      K is a counter
C      IX is the Integer input value
       ISIZE = 15
       Y = 0.0
       K = 0
       TEMP = 0
       IX = 0

C      The Following is the query for the integer value
       WRITE(6,10) " Please enter an integer."
10     FORMAT (1X, A30)
       READ(5,11) IX
11     FORMAT (I6)

C      This Outputs the Integer Value
       WRITE(6,12) IX
12     FORMAT(1X, "The base 10 value of the input is: ",I7)

C      This Section of code  transforms the integer to binary
C      MOD determines the remainder
C      The Number is then divided for the next iteration
       DO 31 I = ISIZE, 1, -1
          TEMP =MOD(IX,2)
          IF(TEMP .GT. 0) GOTO 33
          GOTO 37
33        INPUT(I) = 1
          K = I
          GOTO 38
37        INPUT(I) = 0
38        IX = IX / 2
31        CONTINUE

C      This is the output for the converted integer to binary
       WRITE(6,14) (INPUT(J), J = K ,ISIZE)
14     FORMAT (2X, "The base  2 value of the input is: ",10(10(I1)))


C      This is the query for the deicmal valur
       WRITE(6,10) " Please enter decimal value."
       READ(5,21) Y
21     FORMAT (F6.6)

C      This section outputs the input decimal value
       WRITE(6,34) Y
34     FORMAT(1X, "The base 10 value of the input is: ",F7.6)
       ISIZE = 6
       
C      This converts the decimal to binary
C      Every value greater than 1 has 1 subtracted
C      The value is then multiplied x2 and the process is repeated
       DO 45 L = 1, 6
          IF(Y .GE. 1.0) GOTO 47
          GOTO 49
47        Y =Y-1
49        Y = Y*2
          IF(Y .GE. 1.0) GOTO 59
          GOTO 46
59        MINPUT(L) = 1
          K = L
          GOTO 45
46        MINPUT(L) = 0
45        CONTINUE

C      This is the output for the converted decimal to binary
       WRITE (6, 55) (MINPUT(J), J = 1 ,K)
55     FORMAT (2X, "The base  2 value of the input is: .",10(10(I1)))

       STOP
       END








