Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. ## Boolean variable problem

This, once again, is my school assignment that I need help on.

problem:

When you go on a date, you rate your date's fashion sense on a scale from 0 to 10. As a general rule, if the rating is 8 or more, then you will consider going out again with the same person. However, if your date's parents are wealthy, you will consider going out again with him or her if the rating is 7 or more.

If the int r contains your date's rating from 0 to 10 and the boolean w contains true if and only if your date's parents are wealthy, write code that will set d to true if and only if you will consider going on another date with the same person.

Here's what I've gotten to so far:

```
d = r > 8;
if (w = true);
d = r > 7;```

Thanks.

2. ## Re: Boolean variable problem

I know the variable names were given to you, but when you have the flexibility, give your variables decent names. Single letter variable names are only acceptable as loop control variables, and that's more by convention than anything else. Give even loop control variables longer names if it helps you understand your program better.

It also helps to comment your code. In this case, just follow the instructions given in the assignment:
```// if the date's fashion sense, r, is greater than or equal to 8, consider going out again:
if ( r >= 8 )
{
// d is true if another date is possible
d = true;
}

// or if the parents are wealthy, w is true, then the date is acceptable with a fashion sense of 7 or more
if ( w && r >= 7 )
{
d = true;
}```
That's not the answer, because the OR that begins the second comment has to be included in the code somewhere, and the value of d for the case when the date is not acceptable has to be set. You should be able to figure those details out.