C      Programmer:                           Kimberly Hart
C      Course:                               CS430
C      Date Due:                             September 12,2007
C      Language:                             Fortran
C      Compiler used:                        Force 2.0
C      Source Filename:                      ProgB.f
C      Executable Filename (if any) or None: ProgB.exe
C      Professor:                            Elizabeth Adams
C      Description of the program's PURPOSE:   To convert a decimal in
C      base ten to a binary decimal(base 2).
C      Description of program's required INPUT: This program takes one input
C      of a base ten decimal number such as .5
C      Description of program's expected OUTPUT: The output of this program
C      is the binary equivalent of the input to at most 6 decimal places as well
C      as prompts and labels for input and output.
C      Descriptions of any MODIFICATIONS made in debugging the program: No
C      modifications made in general
C      General COMMENTS about the PROGRAM: This program is written in Fortran.
C      It uses an array.  It uses a do loop and lots of formatting.
C      General COMMENTS explaining the syntax or features of the LANGUAGE
C      See inside comments in the program for more information.  Fortran always
C      passes by reference.  Arrays must be dimensioned.

C      Array is dimensioned in this fashion, 6 is the length of the array
       DIMENSION I(6)
C      Prompt for input from user, via 6, the default device(keyboard)
       WRITE (6,17) "Enter a base 10 decimal to convert to binary: "
C      The 17 from the write statement is used to reference its proper format
C      statement which can be anywhere in the program as long as it has a 17
C      to identify it.
17     FORMAT (1X,A50)
       READ (5,19) REALDEC
C      Formatting such as F7.6 means a Fixed point with 7 "characters" and
C      6 after the decimal point.
19     FORMAT (F7.6)
C      Input is echoed
       WRITE(6,21) "The number you entered was: " , REALDEC
21     FORMAT(1X, A28, F7.6)
       REALDEC = REALDEC * 2
C      Do loop that loops through the array spots.  The 23 is used to reference
C      its continue
       DO 23 M = 1,6
C      GE means greaterthan or equal to, all equality operators are used in
C      the form variable.equalityoperator.variable.  A go to is used to
C      delineate what to do if the condition is met.  If not the program
C      simply executes the next line of code.
        IF (REALDEC.GE.1) GO TO 29
          I(M) = 0
C      This go to is used to make sure the next line doesn't execute
          GO TO 28
29        I(M) = 1
C      The next if statement causes the program to exit the do loop when
C      1.0 has been reached.
28        IF (REALDEC.EQ.1.000000) GO TO 24
C      The next line sets up the variable for the next execution in the do loop
          REALDEC = REALDEC * 2
C      The continue associated with the do loop that allows it to loop
23     CONTINUE

24     WRITE (6,33) "The binary decimal is: "
33     FORMAT (A24)
C      Outputs the answer
       WRITE(6,36) ".",(I(K), K=1,M-1)
C      6I1 outputs each element of the array(6 elements) with one space between
C      each element.
36     FORMAT(A1,6I1)
C      Every Fortran program must have a stop and an end
       STOP
       END

