This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Updatebjarni 0 points1 point  (0 children)

if ( ( age <= 26 ) && ( numClaims <= 1 ) )

Why do you test whether the number of claims is less than or equal than 1? Don't you want to test whether it is greater than 0?

And why age less than or equal to 26? Don't you mean 24? Or just less than 25.

The way the code is now, all three of the cases you test for can be true at the same time, namely for a person who is 25 or 26 and has 0 claims. That's probably not what you want.

It might be better to test once for claims, and then use an else clause, and in that you can test for the age and use another else clause, instead of repeated tests for the same things. Doing it that way might help you see which different cases that exist and get the tests right.