64.6k views
1 vote
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 Answer

2 votes

Answer:

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");

}

}

}

Step-by-step explanation:

  1. Create and Initilize the int variable numberOfSides (You can also receive this from a user using the scanner class for example).
  2. create a boolean variable isQuadrilateral
  3. Use if and else statement to check if numberOfSides ==4 and assign true to isQuadrilateral else assign false
User Karmen Blake
by
8.3k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.