# Boolean variable problem

Printable View

• August 29th, 2013, 06:38 PM
ghostheadx
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:

Code Java:

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

Thanks. :confused:
• August 29th, 2013, 06:54 PM
GregBrannon
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:
Code java:

```// 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.