Ask Question

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.

+3
Answers (1)
  1. 27 March, 08:47
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers