1) Convert the English expression “If weight is greater than 150” to a Java expr
ID: 671612 • Letter: 1
Question
1) Convert the English expression “If weight is greater than 150” to a Java expression
2) Convert the English expression “If the value is between 0 and 100 inclusively” to a Java expression
3) Convert the English expression “If the answer is neither “No” or “no” “ to a Java expression
4) Write an if statement to check if val1 and val2 are greater than val3
5) I have a moving box that is represented by four variables: xLoc, yLoc, width and height. xLoc and yLoc describe the location of the upper left corner of the box. The boundaries of the screen are represented by the constants LEFT_EDGE, RIGHT_EDGE, TOP_EDGE and BOTTOM_EDGE. Write an if-statement or nested-if-statment to ensure the moving box is within the boundaries. HINT: think about what the left edge and bottom edge of the box is. IMPORTANT NOTE: 0,0 is in the upper left of the screen … so TOP_EDGE < BOTTOM_EDGE and LEFT_EDGE < RIGHT_EDGE.
Explanation / Answer
1) if(weight > 150)
....
2) if(value >= 0 && value <= 100)
3) if(answer.tolower() != "no")
4) if(val1 > val3 && val2 > val3)
5) if((xLoc >= LEFT_EDGE && xLoc + width <=RIGHT_EDGE) && (yLoc >=TOP_EDGE && yLoc + height <= RIGHT_EDGE))
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.