Ask Question
9 September, 06:06

Assume that a variable variable, number Of Sides has been initialized. Write a statement that assigns the value True to the variable is Quadrilateral if number Of Sides is exactly 4 and False otherwise.

+1
Answers (1)
  1. 9 September, 09:50
    0
    public class ANot {

    public static void main (String[] args) {

    int numberOfSides = 20;

    boolean isQuadrilateral;

    if (numberOfSides==4) {

    isQuadrilateral = true;

    System. out. println ("The triangle is quadrilateral");

    }

    else{

    isQuadrilateral=false;

    System. out. println ("The triangle is not quadrilateral");

    }

    }

    }

    Explanation:

    Create and Initilize the int variable numberOfSides (You can also receive this from a user using the scanner class for example). create a boolean variable isQuadrilateral Use if and else statement to check if numberOfSides = =4 and assign true to isQuadrilateral else assign false
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Assume that a variable variable, number Of Sides has been initialized. Write a statement that assigns the value True to the variable is ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers