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_B.f
C     Executable Filename (if any) or None: none
C     Professor: Adams

C     Description of the program's PURPOSE:
C     To input a decimal number in Base 10 and convert it to Base 2, up to 6 decimal places
C
C     Description of program's required INPUT:
C     a decimal from 0 to 32767
C
C     Description of program's expected OUTPUT:
C     The base 2 representation of the base 10 decimal
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 decimal in RSTORE
      WRITE(6,27)
  27  FORMAT($, 'PLEASE ENTER A DECIMAL NUMBER: ')
      READ (5, 28) RSTORE
  28  FORMAT(F6.5)

      WRITE(6,37)
  37  FORMAT(1X)
C     Echo the input in base 10
      WRITE(6,31) RSTORE
  31  FORMAT('The base 10 value of the input is: ', F6.5)

C     Calculate the base 2 of the decimal
      INDEX = 1
      DO 11 R = -1, -6, -1
         IF (RSTORE - 2**R .GE. 0) THEN
         ICONTAINER(INDEX) = 1
         RNEW = (RSTORE - 2**R)
         RSTORE = RNEW
         INDEX = INDEX + 1
         ELSE
         ICONTAINER(INDEX) = 0
         INDEX = INDEX + 1
         ENDIF
 11   CONTINUE

C     output the base 2 of the decimal
      WRITE(6,52)
  52  FORMAT($, 'The base  2 value of the input is: .')
      WRITE (6,24) (ICONTAINER(I), I = 1,INDEX-1)
  24  FORMAT((6(I1)/1X))

      STOP
      END
