      PROGRAM DILUTE
************************************************************************
* Program to determine how often a mixture of acid and water can be    *
* used before its acidity falls below some specified lower limit, and  *
* to determine the acidity of the diluted mixture after a given number *
* of castings have been immersed in it   Variables used are:           *
*     ACID    :  amount of acid in the mixture                         *
*     WATER   :  amount of water added with each casting immersion     *
*     LIMIT   :  lower limit on acidity                                *
*     MAXNUM  :  maximum number of castings that can be cleaned        *
*     NCASTS  :  number of castings to be cleaned                      *
*     CONCEN  :  proportion of acid in the mixture                     *
*                                                                      *
* Input:   ACID, WATER, LIMIT, NCASTS                                  *
* Output:  MAXNUM, CONCEN                                              *
************************************************************************


      INTEGER MAXNUM, NCASTS
      REAL ACID, WATER, LIMIT, CONCEN

* Enter original amount of acid, amount of water transferred,
* and lower limit on acidity
      PRINT *, 'ENTER ORIGINAL AMOUNT OF ACID, AMOUNT OF WATER ADDED,'
      PRINT *, 'AND THE LOWER LIMIT ON THE ACIDITY:'
      READ *, ACID, WATER, LIMIT

* Calculate and display the maximum number of castings that can
* be cleaned
      MAXNUM = 1 + INT(LOG(LIMIT) / (LOG(ACID) - LOG(ACID + WATER)))
      PRINT *, 'AT MOST', MAXNUM, ' CASTINGS CAN BE IMMERSED BEFORE '
      PRINT *, 'ACIDITY FALLS BELOW', LIMIT

* Enter number of castings to be cleaned
      PRINT *
      PRINT *, 'HOW MANY CASTINGS ARE TO BE CLEANED (AT MOST', 
     +         MAXNUM, ')?'
      READ *, NCASTS

* Calculate and display the acidity after this many castings have
* been immersed
      CONCEN = (ACID / (ACID + WATER)) ** NCASTS
      PRINT *, 'THE PROPORTION OF ACID IN THE MIXTURE AFTER'
      PRINT *, NCASTS, ' IMMERSIONS IS ', CONCEN

      END
