(De Morgan’s Laws) In this chapter, we discussed the logical operators &&, &, | |, |, ^ and !. De Morgan’s laws can sometimes make it more convenient for us to express a logical expression. These laws state that the expression ! (condition1 && condition2) is logically equivalent to the expression (! Condition1 | | ! condition2). Also, the expression ! (condition1 \ \ condition2) is logically equivalent to the expression (! Condition1 && ! condition2). Use De Morgan’s laws to write equivalent expressions for each of the following, then write an application to show that both the original expression and the new expression in each case produce the same value:
- 1. ! (x < 5) && ! (y >= 7)
- 2. ! (a == b) || ! (g ! = 5)
- 3. ! ((x <= 8) && (y > 4))
- 4. ! ((i >4) || (j <= 6))
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Additional Engineering Textbook Solutions
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Starting Out with Python (4th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Degarmo's Materials And Processes In Manufacturing
Introduction To Programming Using Visual Basic (11th Edition)
Problem Solving with C++ (10th Edition)
- 4. The Area of the Target: To decide on prizes for the archery contest, you decided to use the areas of the center and rings. You decided that rings with smaller areas should be worth more points. But how much more? Complete the following investigation to help you decide. a. Find the sequence of the areas of the rings, including the center. (Be careful.) b. Write a recursive formula and an explicit formula for this sequence. C. Write the explicit formula in summation notation. Find the total area of the bull's eye if it had 9 rings around the bull's eye.arrow_forwardComputer Engineering Labarrow_forwardProblem Statement: The mathematician Conway imagined a game, called game of life, whichconsidered cells that are susceptible to reproduce, disappear, or survive when they obey certainrules. These cells are represented by elements on a grid of squares, where a grid has an arbitrarysize. Thus, each cell (except those on the boundaries of the grid) is surrounded by eight squaresthat contain other cells. The rules are stated as follows:1. Survival: Each cell that has two or three adjacent cells survives until the next generation.2. Death: Each cell that has at least four adjacent cells disappears (or dies) by overpopulation.Also, each cell that has at most one adjacent cell dies by isolation.3. Birth: Each empty square (i.e., dead cell) that is adjacent to exactly three cells gives birthto a new cell for the next generation.It is worth noting that all births and deaths occur at the same time during a generation.Write a program that simulates this game and displays all successive…arrow_forward
- part C Darrow_forwardDo not reject if you dont know the answer. Use MatLAabarrow_forward(GREATEST COMMON DIVISOR) The greatest common divisor of integers x and y is the largest integer that evenly divides into both x and y. Write and test a recursive function gcd that returns the greatest common divisor of x and y. The gcd of x and y is defined recursively as follows: If y is equal to 0, then gcd (x, y) is x; otherwise, gcd (x, y) is gcd (y, x % y), where % is the remainder operator.arrow_forward
- For this discussion, we are going to be working with operators. Below is the code for the Operators class, which contains a main() method and a divisible() method. Study the code below, paying special attention to the four if statements. First, explain using complete sentences how each if statement evaluates (true or false), as well as what takes place in each if statement's test (comparisons, function calls, increments/decrements, etc.). Then, provide what the program will output. public class Operators { public static void main(String[] args) { int a = 5, b = 10, c = 11; System.out.println("This program works with operators."); if (a < 10 ^ b == 10) System.out.println("Java "); if (divisible(b, a) | divisible(c, a)) System.out.println("Programming "); if (a + b - (++c) == c - (b--) + 1) System.out.println("CITC ");…arrow_forwardCan you please help me code thisarrow_forwardCompute the weakest precondition for each of the following assignment statements and postconditions. x = 2 * y -5; y = x + 2; {y < 2}arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning