comp.lang.ada
 help / color / mirror / Atom feed
From: haverber@visi.comDELETE_CAPS_TO_RESPOND (Bill Haverberg)
Subject: Re: 'Money wanted' algorithm (Cobol version)
Date: 1996/12/30
Date: 1996-12-30T00:00:00+00:00	[thread overview]
Message-ID: <32c80aab.2893217@news.visi.com> (raw)
In-Reply-To: 32c8f428.76407842@news.dwx.com


renegade@dwx.com (Renegade) wrote:

>congee@mindspring.com (Deric Cheng) wrote:
>>dennis@qltel.exonet.nl (Dennis Janssen) wrote:
>>
>>>Hi Deric,
>>
>>>**>> I  need alot of money badly; Could anyone help?
>>
>>>DC> Step 1 Find empty coffee cup
>>>DC> Step 2 Find busy Street
>>>DC> Step 3 Sit in middle of Street
>>>DC> Step 4 goto Step 3 until sun goes down.
>>>DC> Stpe 5 goto step 1 in the next day.
>>
>>>Tsk, tsk, bad advice. Goto's are evil!
>>
>>>Program Make_Money;
>>
>>>Uses
>>>  Nothing;
>>
>>>begin
>>>  Repeat
>>>    Find(EmptyCoffeeCup);
>>>    Find(BusyStreet);
>>>    Repeat
>>>      Sit(MiddleOfStreet)
>>>    Until Sun(Down)
>>>  Until Hell(FrozenOver)
>>>end.
>>
>>>See mom, I DO have the Christmas spirit!
>>
>>>   Dennis!
>>Hey that's cool can you do it in Cobol?
>
>Sure:
>
>IDENTIFICATION DIVISION.
>PROGRAM-ID 	MAKE-MONEY.
>AUTHOR	              MY- ASS.
>DATE-WRITTEN   TODAY.
>ENVIRONMENT DIVISION.
>   HOPEFULLY WARM.
>DATA DIVISION.
>
>~~~~ YADA, YADA, YADA
>01  HELL-IND                 PIC X     VALUE SPACES.
>   88 HELL-FROZEN                    VALUE 'Y'.
>01   TIME-IND               PIC X      VALUE SPACES.
>   88  SUN-DOWN                        VALUE 'Y'.
>
>PROCEDURE DIVISION.
>
>MAIN.
>   PERFORM DAILY-ROUNTINE UNTIL HELL-FROZEN.
>   STOP-RUN.
>
>DAILY-ROUTINE.
>   PERFORM FIND-EMPTY-COFFEE-CUP.
>   PERFORM FIND-SPOT WITH TEST AFTER UNTIL LOCATION = "GOOD".
>   PERFORM SIT UNTIL SUN-DOWN.
>   IF HELL-TEMP < 32 
>        MOVE "Y" TO HELL-IND.
>
>FIND-EMPTY-COFFEE-CUP.
>   FIND COFFEE-CUP.
>   IF COFFEE-CUP NOT = "EMPTY"
>        PERFORM EMPTY-CUP.
>
>EMPTY-CUP.
>   IF CUP-CONTENTS-APPEAR = "GOOD"
>       DRINK CUP-CONTENTS
>   ELSE
>        POUR CUP-CONTENTS.
>
>FIND-SPOT.
>   MOVE "GOOD" TO LOCATION.
>   FIND SPOT.
>   IF COP-PRESENT = "YES" 
>       MOVE "BAD" TO LOCATION.
>   IF STREET-BUSY = "NO"
>       MOVE "BAD" TO LOCATION.   
>   IF BULLETS-FLYING = "YES"
>       MOVE "BAD" TO LOCATION.
>
>SIT.
>   IF BUTT-ACHES
>       MOVE ASS TO OTHER-SIDE.
>   SIT STILL.
>   LOOK PITIFUL.
>   BEG.
>   PLEAD.
>   IF DARK="YES"
>        MOVE "Y" TO TIME-IND.
>
>Please note:   This program was half the size, and worked twice as
>well until administration got ahold of it and requested rewrites.  Now
>it is bigger, and nobody knows for sure what it does......
>
>Enjoy....
>
>Dave
>
>The opinions expressed in this post are purely my own. 
>You may e-mail replies to:   renegade@dwx.com
>

My K&R is at work so I don't have anything to spot check my code
against...might be a couple syntax errors here and there.

#include <stdio.h>
#include <city.h>

enum { new, battered, travel, captains, porcelain } cupCondition_e;
extern Streets;

typedef {
   enum cupCondition_e condition;
   float amount;
} coffeeCup_t;

int main()
{
   coffeeCup_t CoffeeCup;
   CoffeeCup.condition = battered;
   CoffeeCup.amount = 0f;

   for (i=0; i<Streets.Num && Streets.traffic[i]<50; i++);
   if (Streets.traffic[i]<50) {
      fprintf(stderr, "Town too small, catching bus to big city\n");
      /* Have to implement this part. For now, we assume the 
         freeloader dies of starvation. Phase II replaces this with 
         signal handling.
      */
      exit(1);
   }
   while (1) {
      SitInMiddleOf(&Streets, i);
   }
}





  parent reply	other threads:[~1996-12-30  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-12-30  0:00 'Money wanted' algorithm (Cobol version) Doug Miller
1996-12-30  0:00 ` Sundial Services
1996-12-30  0:00 ` Beldraen
1996-12-31  0:00   ` Constantinos A. Kotsokalis
1996-12-30  0:00 ` Renegade
1996-12-30  0:00   ` 'Money wanted' algorithm (Lisp version) Ken Tilton
1996-12-30  0:00   ` Bill Haverberg [this message]
1996-12-31  0:00   ` 'Money wanted' algorithm (Cobol version) Bob Jarvis
1996-12-31  0:00     ` Deric Cheng
1996-12-31  0:00 ` Brad Dale
     [not found]   ` <32C988BA.427D@dynasty.net>
1997-01-01  0:00     ` Pae Choi
1996-12-31  0:00 ` Robin Becker
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox