C     Programmer: Willson Hayes
C     Course: CS 430
C     Date Due: September 12th, 2007
C     Language: FORTRAN
C     Compiler used: FORCE 2.0
C     Source Filename: PA2_A.f
C     Executable Filename (if any) or None: none
C     Professor: Adams

C     Description of the program's PURPOSE:
C     To input an integer in Base 10 and convert it to Base 2
C
C     Description of program's required INPUT:
C     an Integer from 0 to 32767
C
C     Description of program's expected OUTPUT:
C     The base 2 representation of the base 10 integer
C
C     Descriptions of any MODIFICATIONS made in debugging the program:
C     none
C
C     General COMMENTS about the PROGRAM
C     No exception or error handling.
C
C     This program uses the fixed column format required by early FORTRAN
C
      DIMENSION ICONTAINER(10)

C     Prompt the user for input, store the integer in INTSTORE
      WRITE(6,27)
  27  FORMAT($, 'PLEASE ENTER AN INTEGER: ')
      READ (5, 28) INTSTORE
  28  FORMAT(I5)
  
      WRITE(6,37)
  37  FORMAT(1X)
C     Echo the input in base 10
      WRITE(6,31) INTSTORE
  31  FORMAT('The base 10 value of the input is: ', I5)

C     Calculate the Base 2 of the integer
      RINDEX = 1
      DO WHILE (INTSTORE .NE. 0)
           IREMAINDER = MOD(INTSTORE,2)
           INEW = (INTSTORE / 2)
           INTSTORE = INEW
           ICONTAINER(RINDEX) = IREMAINDER
           RINDEX = RINDEX+1
      ENDDO

C     Output the Base 2 integer
      WRITE(6,52)
  52  FORMAT($, 'The base  2 value of the input is: ')
      WRITE (6,24) (ICONTAINER(I), I = 1,RINDEX-1)
  24  FORMAT((20(I1)/1X))

      STOP
      END




