First REXX Program

Here's my first REXX program I ever wrote!!!
(kicks Hello World! to the curb!)

Essentially it's based upon David Bach's "Latte Factor", except altered for Canadian coffee drinkers.:p
 

 

 

/* REXX EXEC ******************************************************************/
/*
/* TIMMIES FACTOR - COMPOUND INTEREST CALCULATOR */
/*
/* AUTHOR: PAUL GAMBLE */
/* DATE: OCT 1/2007 */
/*
/*
/******************************************************************************/
say '***********************'
say 'Welcome Coffee drinker.'
say '***********************'
DO WHILE DATATYPE(CoffeeAmt) \= 'NUM'
say ""
say "What is the price of your coffee?",
"(e.g. 1.58 = $1.58)"
parse pull CoffeeAmt
END

DO WHILE DATATYPE(CoffeeWk) \= 'NUM'
say ""
say "How many coffees a week do you have?"
parse pull CoffeeWk
END

DO WHILE DATATYPE(Rate) \= 'NUM'
say ""
say "What annual interest rate would you like to see on that money?",
"(e.g. 8 = 8%)"
parse pull Rate
END
Rate = Rate * 0.01 /* CHG TO DECIMAL NUMBER */

DO WHILE DATATYPE(Years) \= 'NUM'
say ""
say "For how many years would you invest coffee money?"
parse pull Years
END

/* CALCULATION */
CoffeeYr = CoffeeWk * 52 /* CAL COFFEES A YEAR */
CoffeeYrAmt = CoffeeAmt * CoffeeYr /*CAL AMT FOR COFFEES A YEAR */
FV = 0

/* CAL FUTURE VALUE OF MONEY SPENT WITH COMPOUND INTEREST */
do i = 1 to Years
FV = FV + CoffeeYrAmt
FV = FV * (Rate + 1)
end

/* DISPLAY THE MONEY SHOT */
say ""
say "-----------------------------------------"
say "Timmies coffee cost: $" CoffeeAmt
say "-----------------------------------------"
say "Timmies per week: " CoffeeWk
say "-----------------------------------------"
say "Cost per week: $" CoffeeAmt * CoffeeWk
say "-----------------------------------------"
say "Timmies per year: " CoffeeYr
say "-----------------------------------------"
say "Cost per year: $" CoffeeYrAmt
say "-----------------------------------------"
say "Interest Rate: " Rate
say "-----------------------------------------"
say "Number of years: " Years
say "-----------------------------------------"
say "Future value of money spent: $" format(FV,,2,0)
say "========================================="
say ""
say "THANK YOU."

 

 

 

 

 

 

2 thoughts on “First REXX Program”

Leave a Reply

Your email address will not be published. Required fields are marked *