C      Programmer:                           Kimberly Hart
C      Course:                               CS430
C      Date Due:                             September 6,2007
C      Language:                             Fortran
C      Compiler used:                        Force 2.0
C      Source Filename:                      ProgA.f
C      Executable Filename (if any) or None: ProgA.exe
C      Professor:                            Elizabeth Adams
C      Description of the program's PURPOSE: This program takes in a decimal
C      base ten number and outputs the binary, base 2 representation of that
C      number.
C      Description of program's required INPUT: This program takes in a
C      base 10 number from the user, this number is to be no larger than
C      32767.
C      Description of program's expected OUTPUT: This program outputs the
C      binary representation of the input given, along with prompts and labels.
C      Descriptions of any MODIFICATIONS made in debugging the program:
C      General COMMENTS about the PROGRAM: This program is written in Fortran.
C      It uses arrays and do loops.
C      General COMMENTS explaining the syntax or features of the LANGUAGE:
C      Fortran is an early programming language.  It always passes by reference,
C      arrays must be dimensioned, and formatting has a special way of being done.
C      See internal comments for more information.

C      This is how arrays are dimensioned.
       DIMENSION I(15)
       
       WRITE (6,17) "Enter a base 10 number to be converted to binary: "
C      A50 means the text will be put in a field of 50 spaces
17     FORMAT (1X,A50)
       READ (5,19) NUMDEC
19     FORMAT (I6)
       IF (NUMDEC.GT.32767) GO TO 38
       WRITE(6,21) "The number you entered was: " , NUMDEC
21     FORMAT(1X, A28, I6)
C      Do loops are constructed this way, 25 is the number used on the continue
C      M=1,16 causes the program to loop from the number 1 - 16.  M can be used
C      in the loop to reference the count the loop is at.
       DO  25 M = 1,16
C      MOD returns the remainder when the first number is divided by the second
C      number.
       IF  (MOD(NUMDEC,2).GT.0) GO TO 29
           I(M) = 0
           GO TO 25
29     I(M) = 1
25       NUMDEC = NUMDEC / 2
       CONTINUE
       WRITE (6,32) "That number's binary equivalent is: "
32     FORMAT(A37)
C      This statement reverses the array which allows for the binary number
C      to be output correctly.
       WRITE(6,33) (I(K), K=15,1,-1)
C      The next format statement places each number one after another to make
C      it look like one number.
33     FORMAT(15I1)
       GO TO 43
C      The next statements are executed if the user puts in a number above 32767
38     WRITE (6,39) "You entered a number that is out of range"
       WRITE (6,39) "The program will now exit due to this"
39     FORMAT (A50)
       GO TO 99
C      If the program exits normally this will be shown to allow the user to know
43     WRITE (6,39) "The program has finish and exited normally"
99     STOP
       END
