Computers in Engineering WWW Site - Example 2.2

# Example 2.2

#### FORTRAN Version

```!
PROGRAM P22
!
!
IMPLICIT NONE
INTEGER :: I,J,AGE,POUNDS,GRAMS
REAL :: DAYS
LOGICAL :: SINGLE
!
!
PRINT *, 'This is Program >> P22  - Read in some data'
!
!
!
!
DO J=1,I
!
!     EXECUTABLE STATEMENTS
!
GRAMS=POUNDS*254
DAYS=AGE*365.25
!
!     PRINT DATA
!
PRINT *,'AGE AND NUMBER OF DAYS :'
PRINT *, AGE,DAYS
PRINT *,'POUNDS AND GRAMS :'
PRINT *, POUNDS,GRAMS
PRINT *,'SINGLE :'
PRINT *, SINGLE
PRINT *,' '
!
!
END DO
STOP
END PROGRAM P22
```
DATA:
```2
19 105
'Jane '              '123 Main street  '
T
36 185
'Michael '           '105 Greene ave'
F
```
OUTPUT:
```
+--------------------------------------------------+
|     32-bit Power for Lahey Computer Systems      |
|   Phar Lap's 386|DOS-Extender(tm) Version 7.0    |
|  Copyright (C) 1986-94 Phar Lap Software, Inc.   |
|           Available Memory = 14880 Kb            |
+--------------------------------------------------+

This is Program >> P22  - Read in some data
Jane           123 Main street
AGE AND NUMBER OF DAYS :
19    6939.75
POUNDS AND GRAMS :
105       26670
SINGLE :
T

Michael        105 Greene ave
AGE AND NUMBER OF DAYS :
36    13149.0
POUNDS AND GRAMS :
185       46990
SINGLE :
F

```

#### Pascal Version

```
{}
{}
{
}
PROGRAM p22 ( input, output);
VAR
age, pds, single_tmp : INTEGER;
days, grams : REAL;
single : BOOLEAN;
{
}
BEGIN
WHILE ( NOT eof ) DO
BEGIN
{
since we cannot read in a boolean from the keyboard
we read an integer 1 or 0 and convert to boolean
}
IF single_tmp = 0 THEN single := FALSE;
IF single_tmp = 1 THEN single := TRUE;
{
Executable statements
}
grams := pds * 454.0;
days := age * 365.25;
{
Print data
}
writeln (age, days);
writeln (pds, grams);
writeln (single)
END { end of while loop }
END.

```
DATA:
```19 105
Jane               123 Main street
1
36 185
Michael            105 Greene ave
0
```