MathCAD




Fig. 6.22. The Fishermen's Problem: 'unprogrammed' Mathcad solution (6_21_fisherman.mcd) - 2


label: Answer = Answer 1

Catch = Answer

Divided = "yes" indicates catch divided

For

Fisherman = 1 To 3

Catch = Catch 1

Catch = Catch - Catch / 3

If Catch > Int(Catch) Then Divided = no

Next

If Divided = no" Goto label

Print

"Answer "; Answer; fish

4. Third step of structuralization: disposal of the label

Input

"Guess"; Answer

Answer = Answer + 1

Do start loop with checking on exit

Answer = Answer 1

Catch = Answer

Divided = "yes"

For

Fisherman = 1 To 3

Catch = Catch 1

Catch = Catch - Catch / 3

If Catch > Int(Catch) Then Divided = no

Next

Loop Until Divided = "yes" end loop

Print

"Answer "; Answer; fish