Why does my boolean test in java always fail?

后端 未结 6 1397
别跟我提以往
别跟我提以往 2021-01-21 21:59

I am trying to make a boolean test so that if one of the tire pressures is below 35 or over 45 the system outputs \"bad inflation\".

In my class I must use a boolean, wh

6条回答
  •  礼貌的吻别
    2021-01-21 22:46

        if (goodPressure = true)
    

    Change this to:

        if (goodPressure == true)
    

    Or even better yet:

        if (goodPressure)
    

    Boolean comparison operators are == and !=. The = is an assignment operator.

    Also, you need to initially set goodPressure = true; before you check for violating conditions.

提交回复
热议问题