You are creating a program that allows student to enter a Boolean expression and you will display
Fantastic news! We've Found the answer you've been seeking!
Question:
You are creating a program that allows student to enter a Boolean expression and you will display the truth table with multiple variables and result.
Transcribed Image Text:
Here are some steps for this program: 1. Prompt the user to enter total count of variables (restrict it to 1-4 variables). 3. 2. Validate the count to make sure the program only allows 1, or 2 or 3 or 4 variables. Prompt the user to enter a Boolean expression (You will use and, or, not boolean operators). You will use the name x, y, z, w for variables, for example, if you have 2 variables, you use x, y. If you have 3 variables, you use x, y, z. For 4 variables, you use x, y, z, w. Some valid expression examples are displayed as follows: not x and not y and not z (equivalent to x'y'z') (equivalent to xy' + z) C. w and not (x or y) or x and not y and z and not w (equivalent to w(x+y)' + xyzw') 4. Validate the expression to make sure that if there are 2 variables, use x, y in the expression. If there are 3 variables, use x,y,z in the expression and if there are 4 variables, use x,y,z,w in the expression. 5. Print Truth Table based on number of variables. If you have 3 variables, you will have 2 = 8 rows. You will have 3 variable columns and 1 output column. See Program Output reference below. a. b. x and not y or z 6. If you use Python, use eval(expression) function to calculate the output for each row. 7. The simplest display is to use a loop for each variable to display each row. If you have 3 variables, you need 3 loops, and for 4 variables, you will have 4 loops. To Solve this problem, we can use the following functions. Function name Purpose of the function getTotal Variables getExpression displayHeader Display Truth Table main Prompt the user to enter total variables (1-4), validate user input and return total count of variables Pass in total count of variables and prompt user to enter expression and return expression. Validate the use of variables in the expression. For 1 variable, use x. For 2 variables, use x,y. For 3 variables, use x,y,z. For 4 variables use x,y,z,w. Use not, and, or boolean operators in the expression. Display header information, the heading of the truth table. (see output below) Display truth table with all variables and output columns main function as the entry of your code Here are some steps for this program: 1. Prompt the user to enter total count of variables (restrict it to 1-4 variables). 3. 2. Validate the count to make sure the program only allows 1, or 2 or 3 or 4 variables. Prompt the user to enter a Boolean expression (You will use and, or, not boolean operators). You will use the name x, y, z, w for variables, for example, if you have 2 variables, you use x, y. If you have 3 variables, you use x, y, z. For 4 variables, you use x, y, z, w. Some valid expression examples are displayed as follows: not x and not y and not z (equivalent to x'y'z') (equivalent to xy' + z) C. w and not (x or y) or x and not y and z and not w (equivalent to w(x+y)' + xyzw') 4. Validate the expression to make sure that if there are 2 variables, use x, y in the expression. If there are 3 variables, use x,y,z in the expression and if there are 4 variables, use x,y,z,w in the expression. 5. Print Truth Table based on number of variables. If you have 3 variables, you will have 2 = 8 rows. You will have 3 variable columns and 1 output column. See Program Output reference below. a. b. x and not y or z 6. If you use Python, use eval(expression) function to calculate the output for each row. 7. The simplest display is to use a loop for each variable to display each row. If you have 3 variables, you need 3 loops, and for 4 variables, you will have 4 loops. To Solve this problem, we can use the following functions. Function name Purpose of the function getTotal Variables getExpression displayHeader Display Truth Table main Prompt the user to enter total variables (1-4), validate user input and return total count of variables Pass in total count of variables and prompt user to enter expression and return expression. Validate the use of variables in the expression. For 1 variable, use x. For 2 variables, use x,y. For 3 variables, use x,y,z. For 4 variables use x,y,z,w. Use not, and, or boolean operators in the expression. Display header information, the heading of the truth table. (see output below) Display truth table with all variables and output columns main function as the entry of your code
Expert Answer:
Answer rating: 100% (QA)
Sure I can help you with that Heres an example implementation in Python that addresses the problem r... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
What determines the success and failure of firms around the globe?
-
Create a program that allows the user to create an estimate of the cost to build a table. This will be a menu-driven program that will continue until the user specifically states that they do not...
-
a) Your roommate heard that you took Fundamentals of Finance with Prof. Hasler and that you learnt about the idea of building a nest egg for your retirement. Your roommate has a crazy idea and asks...
-
Considering all of the below, recommend and justify a price for this deal. This is not easy to do. Put yourself in the shoes of the Robertson managers. Who wants it more? The buyer-Monmouth? The...
-
A piston/cylinder contains 1 kg of liquid water at 20C and 300 kPa. Initially the piston floats, similar to the setup in Problem 4.64, with a maximum enclosed volume of 0.002 m3 if the piston touches...
-
Tully Corporation's Kearney Plant in Jacksonville, Florida, produces the company's weed control chemical solution, Weed Terminator. Production begins with pure water from a controlled stream to which...
-
Explain with the help of neat sketches, the working of two stroke petrol engine.
-
During August 2017, Packer Manufacturing had the following cash receipts and disbursements: Cash received from customers....................................$319,000 Cash received from selling...
-
You are flying your glider around your local airport for fun one late Saturday afternoon in July. The convective currents are great that day. You fly for about 1.5 hours enjoying a perfect day for...
-
The steam cycle of a marine nuclear propulsion plant may be modeled as an ideal Rankine cycle. a . Using the information provided below determine the enthalpy of the working substance in each state....
-
Explain why full employment may be inconsistent with no shirking. Shirking may be likely with full employment because A). it may be possible for employers to pay high wages. B). it may be costless...
-
What is the most important tool for trauma counseling? Explain
-
Correct previous answers if wrong and fill in the rest with an explanation of where the numbers came from. Time Value of Money, Part 2 1. A security has a cost of $1,000 and will return $2,000 after...
-
What can help socially withdrawn 4- and 5-year-old children make gains in their social and emotional development ? Explain
-
How might mirror neurons be related to our feelings of empathy? explain
-
Examine the effect of investment opportunities and value remuneration on an organization's value structure. 7. What are a portion of the benefits and potential downsides related with value funding?...
-
Q7. The incorrect statement regarding secondary valences are: (a) they are ionisable (c) they are non-ionisable (b) attached directly to metal ion (d) equal to the coordination number
-
Suppose that fraction used = / 1.0 + 0.1Mt. for some parameter 1. Write the discrete-time dynamical system and solve for the equilibrium. Sketch a graph of the equilibrium as a function of ....
-
Your supervisor has asked you to research the following situation concerning Owen and Lisa Cordoncillo. Owen and Lisa are brother and sister. In May 2012, Owen and Lisa exchange business pickup...
-
Mike sells his home to Jane on April 2, 2012. Jane pays the property taxes covering the full calendar year in October, which amount to $2,500. How much may Mike and Jane each deduct for property...
-
In 2012, Margaret and John Murphy are married taxpayers who file a joint tax return with AGl of $25,000. During the year they incurred the following expenses: Hospitalization insurance...
-
Two European call options with a strike price of \($50\) are written on two different stocks. Suppose that tomorrow, the low-volatility stock will have a price of \($50\) for certain. The...
-
Which feature best describes a PERT chart? a. It creates a time line of production tasks. b. It creates a work flow for production equipment. c. It identifies the critical path of tasks in a project....
-
\(50 \mathrm{~m}^{3}\) of air at \(18^{\circ} \mathrm{C}\) DBT and \(12^{\circ} \mathrm{C}\) WBT are mixed with \(20 \mathrm{~m}^{3}\) of dry air at \(32^{\circ} \mathrm{C}\) DBT and \(24^{\circ}...
Study smarter with the SolutionInn App