Problem declaring bool

Hi guys

Can someone please help me out here. I'm struggeling with 1 of my assignment questions. It si a multi choice question with 5 possible answers. The answers is a fragment of a program, so in order for me to get the right answer I must compile the whole program and use the correct fragment. I'll give the qeustion. The problem I have is declaring the 2 bool variables beore completing the rest of the program.

A client wants to rent a seaside holiday home for at least four persons. The house must be at most 100 metres from the beach, or it must be situated high with a good view, or there must be satttelite dish tv and space for at least six persons. Suppose the number of persons, num, and distance from beach, dist, have been declared as int, while dish and view are two boolean variables indicating whether the house has a view or sattelite tv. Which of the options below is a correct C++ instruction.

Now I'm not gonna ask you the answer I just want to know how can i declare the bool variables in the correct way so that I can compile the program
bool dish, view; is how you declare two booleans. though shouldn't you be asking what kind of logic needs to be put in the if(num >= 4 && dist <= 100 && ??? ) instead?
They do give me 4 possible answers.

1

if (dist <= 100)
if (num >= 4)
cout << "Yes yes" << endl;
else
if (view)
cout << "Yes yes" << endl;
else
if (dish && num >= 6)
cout << "Yes yes" << endl;



2


if (dist <= 100)
{
if (num >= 4)
cout << "Yes yes" << endl;
}
else
{
if (view)
cout << "Yes yes" << endl;
}
else
if (dish && num >= 6)
cout << "Yes yes" << endl;


This is 2 of the 4 examples given. I want to complile the program myself, but I'm struggeling with getting the values for dish and view

Topic archived. No new replies allowed.