home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / e / e060 / 10.ddi / TUTOR / INVESTOR.RSS < prev   
Encoding:
Text File  |  1986-03-31  |  3.9 KB  |  152 lines

  1. /*  INVESTOR.RSS    This rule set was created to show the basic    */
  2. /*            difference between forward and backward        */
  3. /*            chaining.  It is intentionally small and    */
  4. /*            thus, incomplete.                  */
  5.  
  6. GOAL: advice
  7.  
  8. INITIAL:
  9.     e.tryp        = "e"        /* Test premises eagerly    */
  10.     e.rigr        = "m"        /* Accept minimal certainty    */
  11.     e.lstr        = 80        /* Maximum string length is 80    */
  12.     e.deci        = 0        /* No digits after the decimal    */
  13.     advice        = unknown
  14.     goodsave    = unknown
  15.     goodincome    = unknown
  16.     income        = unknown
  17.     savings        = unknown
  18.     steady        = unknown
  19.     needincome    = unknown
  20.     dependents    = unknown
  21.     newcash        = unknown
  22.     clear
  23.     at 2,28 output "QUICK INVESTMENT ADVISOR"
  24.     output ""; output""
  25.     input newcash num with "What amount of money would you like to invest? "
  26.  
  27. DO:    /* This section is executed after the rules have been processed  */
  28.  
  29.     output ""; output ""
  30.     output "Based on the given information:"
  31.     output ""
  32.     sp = "        "        /* spaces to pad output */
  33.     test advice
  34.     case "stocks":
  35.         output sp,"You should invest the full amount in stocks"
  36.         break
  37.     case "savings":
  38.         output sp,"You should put the full amount into savings"
  39.         break
  40.     case "split":
  41.         output sp,"You should split the money between stocks and savings"
  42.         break
  43.     endtest
  44.     e.deci = 2
  45.     output ""; output ""    /* This is the last command in the consultation    */
  46.  
  47. RULE:    R1
  48.     IF:    not goodsave
  49.     THEN:    advice = "savings"
  50.     REASON: If the client does not have enough in 
  51.         savings, the advice is to put all the
  52.         money in savings.
  53.  
  54. RULE:    R2
  55.     IF:    goodsave and not goodincome
  56.     THEN:    advice = "split"
  57.     REASON: If the client has sufficient savings, but
  58.         not a good income, then the advice is to
  59.         split the money between stocks and savings.
  60.  
  61. RULE:    R3
  62.     IF:    goodsave and goodincome
  63.     THEN:    advice = "stocks"
  64.     REASON:    If the client has a good income and enough
  65.         in savings, then the advice is to invest in
  66.         stocks.
  67.  
  68. RULE:    R4
  69.     IF:    not steady
  70.     THEN:    goodincome = false
  71.     REASON: If the income for the next year is not
  72.         steady, then it is not good income.
  73.  
  74. RULE:    R5
  75.     IF:    income <= needincome
  76.     THEN:    goodincome = false
  77.     REASON: If the income is less than that needed by
  78.         a family of this size, then it is not a
  79.         good income.
  80.  
  81. RULE:    R6
  82.     IF:    steady and (income > needincome)
  83.     THEN:    goodincome = true
  84.     REASON: To have good income, the client's employment
  85.         must be steady.
  86.  
  87. RULE:    R7
  88.     IF:    known("dependents")
  89.     THEN:    needincome = 15000 + (dependents * 4000)
  90.     REASON:    If we know the number of dependents, then the
  91.         needed income is $15,000 plus $4000 times the
  92.         number of dependents.
  93.  
  94. RULE:    R8
  95.     IF:    savings > (5000 * dependents)
  96.     THEN:    goodsave = true
  97.     REASON: If savings is greater than $5000 per dependent,
  98.         then it is sufficient savings.
  99.  
  100. RULE:    R9
  101.     IF:    savings <= (5000 * dependents)
  102.     THEN:    goodsave = false
  103.     REASON: If savings is less than $5000 per dependent,
  104.         then it is not sufficient savings.
  105.  
  106.  
  107. /*  Variables are defined below with their label and prompt clause    */
  108.  
  109. VAR:    NEWCASH
  110.     LABEL:    Amount of cash to invest
  111.  
  112. VAR:    ADVICE
  113.     LABEL: The advice given
  114.  
  115. VAR:    GOODINCOME
  116.     LABEL: Income is good
  117.  
  118. VAR:    GOODSAVE
  119.     LABEL: Savings are good
  120.  
  121. VAR:    NEEDINCOME
  122.     LABEL:    Income needed
  123.  
  124. VAR:    INCOME            /*  Note: the backslash continues a     */
  125.                 /*  command on the following line.    */
  126.     FIND:    output ""
  127.         input income num with \
  128.             "What is your annual household income? "
  129.     LABEL:    Current income
  130.  
  131. VAR:    SAVINGS
  132.     FIND:    output ""
  133.         input savings num with \
  134.             "How much do you have in savings? "
  135.     LABEL:    Current savings
  136.  
  137. VAR:    STEADY
  138.     FIND:    output ""
  139.         input steady str using "u" with \
  140.             "Can you expect a steady income over the next year? (y/n) "
  141.         steady = (steady = "Y")
  142.             /* This changes steady from Y/N to true/false */
  143.     LABEL:    Income is steady
  144.  
  145. VAR:    DEPENDENTS
  146.     LABEL:    Number of dependents
  147.     FIND:    output ""
  148.         input dependents num using "dd" with \
  149.             "How many dependents do you have? "
  150.  
  151. END:
  152.