Question

In: Advanced Math

Rule Based System 1. Given the rule following rules from the class notes on production rules...

Rule Based System

1. Given the rule following rules from the class notes on production rules to convert an Arabic number less than 40 to a roman numeral. USING LOGIC

Rule 1: if x is null then prompt the user and read x

Rule 2: if x is higher than 999 then print “too Big” and make x null

Rule 3: if x is between 10 and 39 then print “X” and reduce x by 10

Rule 4: if x is equal to 9 then print “IX” and reduce x to 0

Rule 5: if x is between 5 and 8 then print “V” and reduce x by 5

Rule 6: if x is equal to 4 then print “IV” and reduce x to 0

Rule 7: if x is between 1 and 3 then print “I” and reduce x by 1

Rule 8: if x is equal to 0 then print “end-of-line” and STOP

A. What additional rules are needed to convert an Arabic number less than 1000?

* notice rule 2 has already been changed

** hints: 50 is L; 100 is C; 500 is D; 1000 is M

B. Show the rules fired and the working memory to convert 864 into a roman numeral.

Solutions

Expert Solution

SOLUTION A.

RULE 9: if x is between 40 and 49 then print “XL” and reduce x by 40.

RULE 10: if x is between 50 and 89 then print “L” and reduce x by 50.

RULE 11: if x is between 90 and 99 then print “XC” and reduce x by 90.

RULE 12: if x is between 100 and 399 then print “C” and reduce x by 100.

RULE 13: if x is between 400 and 499 then print “CD” and reduce x by 400.

RULE 14: if x is between 500 and 899 then print “D” and reduce x by 500.

RULE 15: if x is between 900 and 999 then print “CM” and reduce x by 900.

SOLUTION B.

x : 864 memory: NULL (initially)

RULE : 1 memory: 864(copy in memory) Output:

RULE : 14 memory: 364 (864-500) Output: D

RULE : 12 memory: 264 (364-100) Output: DC

RULE : 12   memory: 164 (264-100) Output: DCC

RULE : 12 memory: 64 (164-100) Output: DCCC

RULE : 10   memory: 14 (64-50) Output: DCCCL

RULE : 3 memory: 4 (14-10) Output: DCCCLX

RULE : 6 memory: 0 (4-0) Output: DCCCLXIV

RULE : 8 memory: NULL Output: DCCCLXIV end-of-line


Related Solutions

Explain what is rule based system and the fuzzy expert system based on the following information....
Explain what is rule based system and the fuzzy expert system based on the following information. Here is what Amy will do. When the temperature is cold, she will wear a coat. When the temperature is moderate, she will wear a jumper. When the temperature is cold, she will stay indoor. When the temperature is moderate, she will go for shopping. Here is Amy’s consideration for the weather/temperature. It is cold when the temperature is below 16 degree. It is...
Answer the following questions based on HSAB theory. If using Fajans Rules, give the rule number...
Answer the following questions based on HSAB theory. If using Fajans Rules, give the rule number and explain why it applies. 1. Explain why aluminum perchlorate is less soluble than aluminum cyanide. This is unusual since perchorates tend to be very soluble. 2. Explain why the Ksp for FeBr2 is 4.1 x 10–4 and the Ksp for FeF2 is 3.2 x 19–7. 3. Explain why the Ksp for Fe(OH)3 is 1.2 x 10–36 and the Ksp for Fe(OH)2 is 7.8...
Given a parentheses string s, compute the score of the string based on the following rule:...
Given a parentheses string s, compute the score of the string based on the following rule: • If s is not balanced, the score is 0. • () has score 1. • AB has score A + B, where A and B are balanced parentheses strings. • (A) has score 2 * A, where A is a balanced parentheses string. A balanced string satisfies the following requirements: • The number of ‘(’ equals the number of ‘)’ in the string....
From the information given below, compute the time in days for the following notes: Date of...
From the information given below, compute the time in days for the following notes: Date of Note Due Date Time in Days 1. June 28, 2010 August 10, 2010 days 2. March 5, 2010 August 12, 2010 days 3. April 20, 2010 July 17, 2010 days 4. January 12, 2010 May 15, 2010 days 5. December 17, 2010 February 2, 2011 days From the information given below, determine the due date for the following notes:        Date of Note       Time...
Consider the following simple ingress ACL with three rules: Rule 1. If TCP destination port=80 or...
Consider the following simple ingress ACL with three rules: Rule 1. If TCP destination port=80 or TCP destination port=443, then allow connection. Rule 2. If TCP destination port=25 and IP destination address=60.47.3.35, then allow connection. Rule 3. Disallow ALL connections. Now answer the following questions: Why is Rule 2 safer than Rule 1? Which rule in the ACL represents the default behaviour of SPI firewalls for ingress connection-opening attempts? Given the above ACL, what would the firewall do with an...
Given Codd's Rule 4: Rule 4: Dynamic online catalog based on the relational model: The database...
Given Codd's Rule 4: Rule 4: Dynamic online catalog based on the relational model: The database description is represented at the logical level in the same way as ordinary data, so that authorized users can apply the same relational language to its interrogation as they apply to the regular data. In three sentences, explain what this means. Give two example queries from MySQL that show how MySQL realizes the concepts
-1 Two loop rules and a point rule are created for a simple circuit: 10 -...
-1 Two loop rules and a point rule are created for a simple circuit: 10 - 10I2 - 20I1 = 0 10 - 5I3 - 20I1 = 0 I1 = I2 + I3 I1 represents the current coming from the battery. Assume that all currents are positive. What is the equivalent resistance of the circuit? A. 10.0 ? B. 35.0 ? C. 12.7 ? D. 23.3 ? 1.2 For the situation described by the equations given in the previous question,...
1. Based on the profitability index rule, should a project with the following cash flows be...
1. Based on the profitability index rule, should a project with the following cash flows be accepted if the discount rate is 12 percent? Why or why not? Year Year Cash Flow 0 $-26,200 1 $11,800 2 $0 3 $24,900
Based on the Notes Payable Schedule (N-1), the $12,000,000 notes is classified as noncurrent liability. Is...
Based on the Notes Payable Schedule (N-1), the $12,000,000 notes is classified as noncurrent liability. Is this classification appropriate? If not, make the necessary adjusting entry. (hint: refer to the bank confirmation on page 72) (1 point) Apollo Shoes, Inc.                   N-1 Notes Payable Schedule Prepared by For Year Ended 12/31/2017 Reviewed by PBC (Audited) Unaudited Balance Balance Acct # Account Title 12/31/16 Additions Payments 12/31/17 27000 Notes Payable-Noncurrent $0.00 2/2/17 $12,000,000.00 $12,000,000.00 24100 Line of Credit $10,000,000.00 7/1/17 $44,403,000.00 2/2/17...
What is the main difference between legal rules from any other kind of rule of conduct...
What is the main difference between legal rules from any other kind of rule of conduct such as moral and religious rules?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT