Ask Question

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.

+2
Answers (1)
  1. 10 June, 18:29
    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 & 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