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:( :( :-/

that's not a program, that's the assignment for your homework.
First you have to write a program before you can compile it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.