Ask Question
3 October, 00:29

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. 3 October, 02:58
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers