home *** CD-ROM | disk | FTP | other *** search
- \ ╔════════════════════════════════════════════════════╗
- \ ║ Lesson 5 Part 150 F-PC 3.5 Tutorial by Jack Brown ║
- \ ╚════════════════════════════════════════════════════╝
-
- \ Part six of CHKBOOK.SEQ
- /* ************************************************************ */
- /* */
- /* Function: BALANCE - Handle user menu in checkbook program. */
- /* */
- /* Notes: Uses nested IF ... ELSE ... THENs for menu choices */
- /* This is a perfect place for the CASE statement that */
- /* we will be looking at in one of the following lessons */
- /* ************************************************************ */
-
- : BALANCE ( -- flag )
-
- ." You may choose one of the following:" CR CR
- ." (1) Write a check." CR
- ." (2) Make a deposit." CR
- ." (3) Check your balance." CR
- ." (4) Net change this session." CR
- ." (5) Total checks this session." CR
- ." (6) Total deposits this session." CR
- ." (7) Average check written this session." CR
- ." (8) Exit." CR
- ." (9) Reinitialize." CR CR
- ." Enter your choice by typing the corresponding number." CR
-
- SCAN_FOR_INT CR
-
- 1 OVER = IF DROP WRITE_A_CHECK 1 ELSE
- 2 OVER = IF DROP MAKE_A_DEPOSIT 1 ELSE
- 3 OVER = IF DROP 40 HBAR
- ." Your current balance is: "
- BAL_DOLLARS @ BAL_CENTS @ $XX.XX CR
- 40 HBAR 1 ELSE
- 4 OVER = IF DROP NET_CHANGE 1 ELSE
- 5 OVER = IF DROP TOT_CHECKS 1 ELSE
- 6 OVER = IF DROP TOT_DEPOSIT 1 ELSE
- 7 OVER = IF DROP AVERAGE 1 ELSE
- 8 OVER = IF DROP
- 60 CLR_HBAR
- ." Check Book terminated normally "
- ." with a balance of: "
- BAL_DOLLARS @ BAL_CENTS @ $XX.XX CR
- 60 HBAR FAST QUIT ( CR 0 0 BDOS ) ELSE
- 9 OVER = IF DROP 0 ELSE
- 40 CLR_HBAR
- 7 DUP DUP EMIT EMIT EMIT
- ." That choice is unavailable, try again." CR
- ." Type 1, 2, 3, 4, 5, 6, 7, 8 or 9." CR
- 40 HBAR DROP 1
- THEN THEN THEN THEN THEN THEN THEN THEN THEN ;
-
- /* ************************************************************ */
- /* */
- /* Function: Checkbook main function of the checkbook program. */
- /* */
- /* Date: July 21, 1988 */
- /* */
- /* Interface: int checkbook() */
- /* */
- /* Notes: This program will do your checkbook calculations */
- /* Why would anyone use a computer to balance their checkbook? */
- /* */
- /* ************************************************************ */
-
- : MAIN ( -- )
- SLOW
- BEGIN
- BAL_DOLLARS OFF BAL_CENTS OFF TR_DOLLARS OFF TR_CENTS OFF
- OLD_DOLLARS OFF OLD_CENTS OFF CHK_DOLLARS OFF CHK_CENTS OFF
- DEP_COUNT OFF CHK_COUNT OFF DEP_DOLLARS OFF DEP_CENTS OFF
-
- 40 CLR_HBAR
- ." Welcome to your checkbook." CR
- ." Please enter your current balance:" CR
- 40 HBAR
- GET_DOLLARS DUP OLD_DOLLARS ! BAL_DOLLARS !
- GET_CENTS DUP OLD_CENTS ! BAL_CENTS !
- 40 HBAR
- ." Thank you. Your current balance is: "
- BAL_DOLLARS @ BAL_CENTS @ $XX.XX CR
- 40 HBAR
- BEGIN BALANCE 0= UNTIL
- AGAIN ;
-
- \ ╓─────────────╖
- \ ║ Project 5.1 ║
- \ ╙─────────────╜
- \ I would like you to rewrite the Check Book program so that all
- \ arithmetic is performed using the new Fixed Point word set that
- \ was given in Lesson 5 Part 8 and Lesson 5 Part 9. You can modify
- \ The existing program or throw it out and start all over....
- \ it is up to you. If you want to learn any programming language
- \ including FORTH you must read lots of programs, modify lots of
- \ programs and write lots of programs. Here is your chance to learn
- \ to use the new Fixed Point word set in a fairly structured
- \ environment. Good Luck!
-
-