This assignment is for C++, and I will be using VS 2010.
Write a program that will explore various Truth-Tellers and Liars logic problems using C++ conditions. Assume propositions are:
p = “A is truthful”
q = “B is truthful”
r = “C is truthful”
Your program should allow the user to enter T or F for propositions p, q, and r (if necessary), and return the truth value for the below given statement(s). You are basically writing a program to evaluate one row in the truth table and state whether this row is consistent or not (do user choices for p, q, and r match the evaluated statements by A, B, and C).
Deliverables
For credit, your program must at least compile and run properly. It should also contain adequate comments such as:
Basic introductory comments including a brief description, date, and author.
Descriptions of each variable.
Description of significant procedures.
Each student must write and submit his or her own code for the assignment. Discussion of the assignment is allowed. You may share ideas but not code files.
Sample Output (user input in bold and underlined):
Problem 1
Enter T or F for p=’A is truthful’: F
Enter T or F for q=’B is truthful’: T
A says ‘We are both telling the truth’ is FALSE
B says ‘A is lying.’ is TRUE
This is consistent(from the truth table).
Problem 2
Enter T or F for p=’A is truthful’: T
Enter T or F for q=’B is truthful’: F
Enter T or F for r=’C is truthful’: F
A says ‘B or C is lying’ is TRUE
B says ‘C is lying’ is TRUE
C says ‘A and I are both telling the truth’ is FALSE
This is NOT consistent (from the truth table).
L A B S T E P S
STEP 1: Puzzle 1 (15 points)
Back to top
You come across two inhabitants of Smullyan’s Island. A says “We are both telling the truth,” and B says “A is lying.” Allow the user to enter T or F for propositions p and q, and return the truth value for each of these statements and state weather this row is consistent or not (do user choices for p and q match the evaluated statements by A and B). Note: It is a good idea to make a truth table, by hand, before actually doing the program.
Sample Run (user input underlined and in bold):
Problem 1
Enter T or F for p=’A is truthful’: F
Enter T or F for q=’B is truthful’: T
A says ‘We are both telling the truth’ is FALSE
B says ‘A is lying’ is TRUE
This is consistent (from the truth table).
STEP 2: Puzzle 2 (15 points)
Back to top
You come across three inhabitants of Smullyan’s Island. A says “B or C is lying,” and B says “C is lying,” and C says “A and I are both telling the truth.” Allow the user to enter T or F for propositions p, q, and r, and return the truth value for each of these statements and state weather this row is consistent or not (do user choices for p, q, and r match the evaluated statements by A, B, and C). Note: It is a good idea to make a truth table, by hand, before actually doing the program.
Sample Run (user input underlined and in bold):
Problem 2
Enter T or F for p=’A is truthful’: F
Enter T or F for q=’B is truthful’: F
Enter T or F for r=’C is truthful’: T
A says ‘B or C is lying.’ is TRUE
B says ‘C is lying.’ is FALSE
C says ‘A and I are both telling the truth.’ is FALSE
This is NOT consistent(from the truth table).
______________________________________________________________________________________________________________________________________
You should submit a single zip archive containing :
• the entire contents of the project directory including the project files, executable and source code
• a copy of the source (.cpp) file, as a .txt file (as a text file).
