Question: Question(1) Assume that a bool variable isQuadrilatera l has been declared , and that an int variable , numberOfSides has been declared and initialized .

Question(1)

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

Instructor Notes:

Hint: The result of evaluating a conditional expression is true/false, and can be assigned to bool variable, e.g.,

bool x = y == z;

Note == is the relational equality operator and = is the assignment operator. This statement will compare y and z to see if they are equal, which is either true or false. Then the true/false value will be assigned to Boolean variable x.

=========

Question (2)

Assume that a bool variable workedOvertime has been declared , and that an int variable hoursWorked has been declared and initialized . Write a statement that assigns the value of workedOvertime to true if hoursWorked is greater than 40 and false otherwise

=========

Question(3)

Write an if/else statement that compares the value of the variables soldYesterday and soldToday, and based upon that comparison assigns salesTrend the value -1 or 1.

-1 represents the case where soldYesterday is greater than soldToday; 1 represents the case where soldYesterday is not greater than soldToday.

=========

Question(4)

Assume that x is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if x is a letter.

=========

Question(5)

Assume that x is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if x is alphanumeric , that is either a letter or a decimal digit

=========

Question(6)

Assume that c is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if c is a space character

=========

Question(7)

Assume that x is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if x is NOT a upper-case letter

=========

Question(8)

Assume that x is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if x is NOT a letter.

=========

Question(9)

Assume that s is a string . Write an expression whose value is true if and only if the value of s would come between "mortgage" and "mortuary" in the dictionary.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!