114k views
0 votes
Given two variables, isEmpty of type boolean, indicating whether a class roster is empty or not, and numberOfCredits of type int, containing the number of credits for a class, write an expression that evaluates to true if the class roster is not empty and the class is more than two credits.

1 Answer

7 votes

isEmpty of type boolean, indicating whether a class roster is empty or not.

numberOfCredits of type int, containing the number of credits for a class.

The expression that evaluates to true if the class roster is not empty is :

(isEmpty == false) && (numberOfCredits == 3 || numberOfCredits == 1)

Step-by-step explanation:

Two variables, isEmpty of type boolean, indicating whether a class roster is empty or not, and numberOfCredits of type int, containing the number of credits for a class.

An expression that evaluates to true if the class roster is not empty and the class is more than two credits is

(isEmpty == false) && (numberOfCredits == 3 || numberOfCredits == 1)

If isEmpty is false, then the number of credits can be either three or one.

The statement shows the expression.

User Karo
by
5.0k points