Write a program to generate a truth table for a

Write a program to generate a truth table for a given Boolean statement. For example, A + B * C produces the following table:

A B C | B * C | A + B * C

===============================

0 0 0 | 0 | 0

0 0 1 | 0 | 0

0 1 0 | 0 | 0

0 1 1 | 1 | 1

1 0 0 | 0 | 1

1 0 1 | 0 | 1

1 1 0 | 0 | 1

1 1 1 | 1 | 1

Input from the keyboard a string representing a Boolean expression where the operators are the following: ! (NOT), * (AND), + (OR), ^ (XOR). Single sets of parentheses can be used if needed. Covert all letters to uppercase and have one space between each operator. The truth table must be able to handle up to four variables and be in binary order. For example, in the first test case, if the Boolean values of A, B, and C were replaced with 1’s for true and 0’s for false, the Boolean combination with the smallest binary representation would come first.

Output to the screen a truth table for the given Boolean expression. The first column of the truth table should represent A, the second B, the third C, and so on. Each binary operation must have its own column and all columns must be labeled. The entries in each column should be aligned and formatted with capital letters like the examples below. Except for the final column, columns do not have to be in any order except the order of operations must be followed to get the correct final answer. Finally, the program should ask if the user wants to run the program again (Check case). Refer to the sample output below.

Sample Run:

Enter the Boolean expression: A + B * C

A B C | B * C | A + B * C

===============================

0 0 0 | 0 | 0

0 0 1 | 0 | 0

0 1 0 | 0 | 0

0 1 1 | 1 | 1

1 0 0 | 0 | 1

1 0 1 | 0 | 1

1 1 0 | 0 | 1

1 1 1 | 1 | 1

Run again (Y/N)? y

Enter the Boolean expression: (!A * B) ^ (B + C)

A B C | !A * B | B + C | (!A * B) ^ (B + C)

=================================================

0 0 0 | 0 | 0 | 0

0 0 1 | 0 | 1 | 1

0 1 0 | 1 | 1 | 0

0 1 1 | 1 | 1 | 0

1 0 0 | 0 | 0 | 0

1 0 1 | 0 | 1 | 1

1 1 0 | 0 | 1 | 1

1 1 1 | 0 | 1 | 1

Run again (Y/N)? N

Share This Post

Email
WhatsApp
Facebook
Twitter
LinkedIn
Pinterest
Reddit

Order a Similar Paper and get 15% Discount on your First Order

Related Questions

Based on the comments of your peer reviewer, instructor, and

Based on the comments of your peer reviewer, instructor, and information gathered about argumentation, write a summary of what you will approach differently in your final draft. Consult the RISE Model and consider your e.ssay. What have you done well? What do you need to revise? Create either a bulleted

The production and analysis of financial statements are core tasks

 The production and analysis of financial statements are core tasks for accounting professionals. The activities for this final project have traditionally been performed monthly by accountants in most organizations. However, with automation making accounting more efficient, many executives are requiring even more frequent financial statements. This new reality further underscores

INTERNET OF THINGS (Topic) Research paper At least five appropriate,

INTERNET OF THINGS (Topic) Research paper  At least five appropriate, properly cited sources . Your project (paper) will comprise 2500 to 3000 words (not including title and reference pages). Your project (paper) must be formatted according to APA guidelines as a Word document, double spaced, Times New Roman, 12-font, with

Environmental film that is called “Into the Americas, Part of the

Watching an environmental film that is called “Into the Americas, Part of the Series: The Story of Cats.” from Kanopy. https://www.kanopy.com/product/americas-0. For Page1, paraphrase what the movie presented (Paragraph 1) and your opinion of the film’s presentation of the issue (Paragraph 2). Read TWO separate professional reviews of the film,

The idea of terrisom with muslims.Why do actions of fews affect one

 Topic that is in the news, however, a) it must not be editorial unless substantiated by facts and b) it must be related to Homeland Security. Reaction papers are a critical component of the conversation that will take place in this course. There will be a total of five different

300–500 words The SWOT analysis is often used to help

300–500 words The SWOT analysis is often used to help managers understand the competitive advantage of their organization. It can also help them to make decisions to support the organization’s mission and vision in an ethical manner and help with strategic planning. (links to videos below) Watch the video: Putting

As a program director, you would have the responsibility of

  As a program director, you would have the responsibility of conducting program evaluations. The Riverbend City scenario, A Day in the Life of a Human Services Leader, provides some insight into how a program director may need to conduct different types of program evaluations to meet various requests for

Outlining the public health financing process is an intuitive phase.

  Outlining the public health financing process is an intuitive phase. Many public health officials start drafting the program budget along with the planning phase just to have some idea of the funding needed to support such a venture. Later, financial analysts are consulted to form a detailed plan of

Review the “Marketing Excellence: BMW” uploaded. This is comprised of

   Review the “Marketing Excellence: BMW” uploaded. This is comprised of two parts; one part respond to questions, and the other to complete a case analysis. Part 1 Evaluate this case, and respond to each of the following questions using both theory and practical managerial thinking. Examine and apply the

Need the solution for HW 4 by 10 am Chicago

Need the solution for HW 4 by 10 am Chicago time.  Only accept if you can guarantee a 100% working code, rating will be given accordingly.  Have attached hw 3 question document for reference. Please use the hw solution file as the data source for hw4. Please note: Coding needs

Economics-NBA & Foreign Player Research Analysis

To note, the majority of the assignment is both research, analysis and a proposal. Given the calculations/background involved, the writer should ideally be someone versed in Economics calculation/concepts in order to be able to address the research portion easier. Also, given the small turn around window, if there is minimal

Examine the importance of professional associations in nursing. Choose a professional nursing organization that relates to your specialty area, or a specialty area in which you are interested. In a 75 Nursing Assignment Help

Examine the importance of professional associations in nursing. Choose a professional nursing organization that relates to your specialty area, or a specialty area in which you are interested. In a 750-1,000 word paper, provide a detailed overview the organization and its advantages for members. Include the following: 1. Describe the

Provide a Write a 1 to 2 page paper that

Provide a Write a 1 to 2 page paper that discussing a practical example of System Engineering in APA format with viable sources to solidify your thoughts presented. Your references must not be more than 5 years old and no more than one entity source and no more than one

One of the most important questions that potential employees are

One of the most important questions that potential employees are asked in an interview is “Tell me about yourself.” It also seems to be one of the hardest questions for interviewees to answer. This question will often be one of the first questions asked and will shape the remainder of

PAYMASTER Project Plan Outline – Premium Paper Help

Premium Paper Help is a professional writing service that provides original papers. Our products include academic papers of varying complexity and other personalized services, along with research materials for assistance purposes only. All the materials from our website should be used with proper references.

Kacie Benson, a 19 year-old woman, is a client on

   Kacie Benson, a 19 year-old woman, is a client on your unit as a result of a skiing accident. She is unconscious and may or may not regain consciousness. She is on complete bedrest. She requires frequent repositioning to maintain correct body alignment and attention to her ROM. She