C     PROGRAMMER: AUSTIN KEELEY
C     COURSE: CS 430 PROGRAMMING LANGUAGES
C     DUE DATE: SEPTEMBER 13, 2007
C     LANGUAGE: FORTRAN 77
C     COMPILER USED: FORCE 2.0.8
C     SOURCE FILENAME: PARTA.F
C     EXECUTABLE FILENAME (IF ANY): PARTA.EXE
C                                   (NOT INCLUDED WITH SUBMIT)
C     PROFESSOR: ELIZABETH ADAMS

C     PURPOSE: THIS PROGRAM CONVERTS AN INTEGER FROM DECIMAL (BASE 10)
C              TO BINARY (BASE 2). SEE BELOW FOR DETAILS ABOUT
C              INPUTS AND OUTPUTS.

C     INPUT: ONE POSITIVE INTEGER THAT IS BETWEEN 0 AND 37267.

C     OUTPUT: THE INPUTTED INTEGER IN BASE 2 (BINARY).  THE OUTPUT
C             IS LIMITED TO 15 DIGITS.  THE LARGEST OUTPUT IS
C             111111111111111

C     GENERAL COMMENTS: NUMBERS ARE ASSUMED TO BE POSITIVE.  NO ERROR
C             CHECKING IS PERFORMED.  THIS PROGRAM USES THE FIXED
C             COLUMN FORMAT REQUIRED BY EARLY FORTRAN.  THIS WORK
C             COMPLIES WITH THE JMU HONOR CODE.

C     GENERAL COMMENTS ABOUT THE LANGUAGE: NONE

C     ------------------------------------------------------------------


C     THIS IS THE ARRAY THAT WILL HOLD INTEGERS FROM THE MOD FUNCTION.
C     IT WILL HOLD DIGITS THAT ARE EITHER 1 OR 0.
      DIMENSION IBINARY(15)

C     PROMPT THE USER TO ENTER A N INTEGER.  THIS INTEGER SHOULD
C     FOLLOW THE CONSTRAINTS LISTED ABOVE.
      WRITE (6, 10) 'PLEASE ENTER AN INTEGER IN BASE 10: '
  10  FORMAT (1X, A37)

C     READ IN THE INTEGER.  THE INTEGER IS LIMITED TO 5 PLACES.
      READ (5, 11) INPUT
  11  FORMAT (I5);

C     ECHO THE INPUT BACK TO THE USER.
      WRITE (6,15) 'YOU ENTERED ', INPUT
  15  FORMAT (1X, A12, I5)

C     LOOP AND PERFORM MOD FUNCTIONS TO GET THE BINARY REPRESENTATION.
C     THE ALGORITHM IS AS FOLLOWS: MOD THE NUMBER AND STORE THE
C     REMAINDER.  THEN DIVIDE THE NUMBER AND REPEAT.
      DO 12 M = 15, 1, -1
         IBINARY(M) = MOD(INPUT, 2)
         INPUT = INPUT / 2
  12  CONTINUE

C     SHOW THE BINARY REPRESENTATION OF THE NUMBER.
      WRITE (6, 13) 'IN BINARY THAT EQUALS ', (IBINARY(I), I = 1, 15)
  13  FORMAT (//1X, A22, 15I1)

C     TELL THE USER THAT THE PROGRAM HAS ENDED.
      WRITE (6, 14) 'END OF PROGRAM'
  14  FORMAT(A14)


C     END OF PROGRAM.
      STOP
      END
