Question: A game called WFF 'N PROOF uses the following three rules to define a well-formed formula, or WFF 1. 2. 3. Any one of the

 A game called WFF 'N PROOF uses the following three rules

A game called WFF 'N PROOF uses the following three rules to define a well-formed formula, or WFF 1. 2. 3. Any one of the letters p, q, r, or s is a WFF A letter N, followed by a WFF, is a WFF Any one of the letters C, A, K, or E, followed by two WFFs, is a WFF. For instance, the following are WFFs Np Kpq NNp Rule 1 Rules 1 and 2 Rules 1 and 3 Rules 1 and 2 (twice) Rules 1, 2, and 3 The following, however, are not WFFs: pq NE Using this recursive definition, you can construct quite complicated WFFs. Prove to yourself that this string represents a WFF NNECpNKNpAqr:s Write recursive method called WFF. Write a main method program that reads in character strings and determines whether they represent WFFs use the method WFF. Note that, in the rules above, some letters are uppercase and some are lowercase. Your program must be case sensitive. (That is, "Apq" is a WFF but "APQ" is not.) Input The input consists of strings of characters, one per line, and each representing a possible WFF to be checked. The input is in a file called www.in. Output For each input line print two output line, one line contains the inputted string, the other line contains the results of the WFF test. A game called WFF 'N PROOF uses the following three rules to define a well-formed formula, or WFF 1. 2. 3. Any one of the letters p, q, r, or s is a WFF A letter N, followed by a WFF, is a WFF Any one of the letters C, A, K, or E, followed by two WFFs, is a WFF. For instance, the following are WFFs Np Kpq NNp Rule 1 Rules 1 and 2 Rules 1 and 3 Rules 1 and 2 (twice) Rules 1, 2, and 3 The following, however, are not WFFs: pq NE Using this recursive definition, you can construct quite complicated WFFs. Prove to yourself that this string represents a WFF NNECpNKNpAqr:s Write recursive method called WFF. Write a main method program that reads in character strings and determines whether they represent WFFs use the method WFF. Note that, in the rules above, some letters are uppercase and some are lowercase. Your program must be case sensitive. (That is, "Apq" is a WFF but "APQ" is not.) Input The input consists of strings of characters, one per line, and each representing a possible WFF to be checked. The input is in a file called www.in. Output For each input line print two output line, one line contains the inputted string, the other line contains the results of the WFF test

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!