Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 448 | Replies: 1
![]() |
•
•
Join Date: Apr 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
An island has two kinds of inhabitants:
Knights: Always tell the truth
Knaves: Always Lie
You encounter two people A and B. You ask the user to enter what A and B say. Your program
should output the conclusions (if possible) about the identities of A and B.
For example (done in class):
-----------------------------------------------------------------
-----------------------------------------------------------------
Solving the ISLAND PUZZLE program
-----------------------------------------------------------------
-----------------------------------------------------------------
Please enter what A says: B is a knight
Please enter what B says: The two of us are of opposite types
-----------------------------------------------------------------
-----------------------------------------------------------------
The result that we can conclude is:
A is a knave
B is a knave
-----------------------------------------------------------------
-----------------------------------------------------------------
Some answers you MIGHT expect from the user concerning what A and B say are:
1- Nothing (i.e. one of them simply says nothing)
2- At least one of us is a knave
3- At least one of us is a knight
4- We are both knights
5- We are both knaves
6- A is a knave
7- B is a knave
8- A is a knight
9- B is a knight
10- I am a knight
11- I am a knave
Knights: Always tell the truth
Knaves: Always Lie
You encounter two people A and B. You ask the user to enter what A and B say. Your program
should output the conclusions (if possible) about the identities of A and B.
For example (done in class):
-----------------------------------------------------------------
-----------------------------------------------------------------
Solving the ISLAND PUZZLE program
-----------------------------------------------------------------
-----------------------------------------------------------------
Please enter what A says: B is a knight
Please enter what B says: The two of us are of opposite types
-----------------------------------------------------------------
-----------------------------------------------------------------
The result that we can conclude is:
A is a knave
B is a knave
-----------------------------------------------------------------
-----------------------------------------------------------------
Some answers you MIGHT expect from the user concerning what A and B say are:
1- Nothing (i.e. one of them simply says nothing)
2- At least one of us is a knave
3- At least one of us is a knight
4- We are both knights
5- We are both knaves
6- A is a knave
7- B is a knave
8- A is a knight
9- B is a knight
10- I am a knight
11- I am a knave
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Linear Mode