Ask Question
14 December, 02:49

Assume that a bool variable is Quadrilateral has been declared, and that an int variable, number Of Sides has been declared and initialized. Write a statement that assigns the value of is Quadrilateral to true if number Of Sides is exactly 4 and false otherwise.

+4
Answers (1)
  1. 14 December, 05:38
    0
    if (numOfSides==4) {

    isQuadrilateral=true;

    }

    else {

    isQuadrilateral = false;

    }

    Explanation:

    See below a complete program that prompts user to enter number of sides of the triangle

    import java. util. Scanner;

    public class TestClock {

    public static void main (String[] args) {

    Scanner in = new Scanner (System. in);

    System. out. println ("Enter the number of sides of the triangle");

    int numOfSides = in. nextInt ();

    boolean isQuadrilateral;

    if (numOfSides==4) {

    System. out. println ("This is Quadrilateral");

    isQuadrilateral=true;

    }

    else {

    System. out. println ("This is not Quadrilateral");

    isQuadrilateral = false;

    }

    }

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Assume that a bool variable is Quadrilateral has been declared, and that an int variable, number Of Sides has been declared and ...” 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