Question
Complete the following exercises: Assume b1 and b2 are declared Java boolean variables. Write a Java expression for each of the following Boolean statements: b1
Complete the following exercises:
Assume b1 and b2 are declared Java boolean variables. Write a Java expression for each of the following Boolean statements:
b1 and b2
either b1 or b2
b1 but not b2
not b1 but b2
either b1 or not b2
either not b1 or b2
neither b1 nor b2 (note this is not the same as 1f)
not b1 and not b2
either b1 or b2 but not both b1 and b2 (this is called exclusive-or)
Assume the boolean variables b1 from b2 from question 1 have been assigned values: b1 = true and b2 = false. What is the resulting (boolean) value of evaluating each of the expressions from question 1? Remember the order of operations of boolean operators: not is evaluated before and, which is evaluated before or.
In Boolean (Predicate) Logic, there are some additional operators that are often used:
The implication () operator is defined as:
A | B | A B |
---|---|---|
true | true | true |
true | false | false |
false | true | true |
false | false | true |
Implement the implication operator as a Java method
The equivalence () operator is defined as:
A | B | A B |
---|---|---|
true | true | true |
true | false | false |
false | true | false |
false | false | true |
Implement the equivalence operator as a Java method
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started