Question

In: Computer Science

Write a program that inputs the values of three Boolean variables, a, b, and c, from...

Write a program that inputs the values of three Boolean variables, a, b, and c, from a “cin” operator (user gives the values be sure to prompt user for what they have to give!). Then the program determines the value of the conditions that follow as true or false. 1. !(a&&b&&c) && ! (a||b||c) 2. !(a||b)&&c Output should include the values of a,b,c ie 0 or 1 in the patterns that follow reflecting the Boolean logic being tested. Where “True” or “False” are in string variables. Study this example! for input of a=1 and b =0 and c=1 results in output looking like !( 1&&0&&1) && !(1|| 0||1) is False !(1||0)&&1 is False Run for the eight cases of a,b,c in Table 3.2 (both editions of text) Warning follow this output example format else you will have to redo it! Hint: your output statements will be large! Hint:. you have to use strings and variables for parts like<< “!(<

Solutions

Expert Solution

Thanks for the question, here is the code in C++

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

#include<iostream>

using namespace std;

// return a valid value either 1 or 0 only

int get_value(int &var, char letter){

               

                do{

                                cout<<"Enter value for "<<letter<<" (1 for true 0 for false): ";

                                cin>>var;

                               

                }while(!(var==1 || var==0));

}

int main(){

               

                int a, b, c;

                get_value(a,'a');

                get_value(b,'b');

                get_value(c,'c');

                cout<<endl<<endl;

                bool d= !(a&&b&&c) && !(a||b||c);

                cout<<"!( "<<a<<" && "<<b<<" && "<<c<<" ) && !( "<<a<<" || "

                                <<b<<" || "<<c<<" ) = "<<boolalpha<<d<<endl;

                cout<<endl;

                bool e = !(a||b)&&c;

                cout<<"!( "<<a<<" || "<<b<<" ) && "<<c<<" = "<<boolalpha<<e<<endl;

}


Related Solutions

Write a Java program that defines two boolean variables a and b and shows that regardless...
Write a Java program that defines two boolean variables a and b and shows that regardless of the values of a and b, the expressions (a && (a || b)) and a are always the same.
Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values.
 in Coral Simulator  Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values. If the input is 7 15 3, the output is: largest: 15 smallest: 3 Your program should define and call two functions: Function LargestNumber(integer num1, integer num2, integer num3) returns integer largestNum Function SmallestNumber(integer num1, integer num2, integer num3) returns integer smallestNum The function LargestNumber should return the largest number of the...
Probability Let A, B and C be Boolean variables denoting three independent events with P(A=1) =...
Probability Let A, B and C be Boolean variables denoting three independent events with P(A=1) = 0.7, P(B=1) = 0.3, and P(C=1) = 0.1. Let D be the event that at least one of A and B occurs, i.e., D = A OR B. Let E be the event that at least one of B and C occurs, i.e., E = B OR C. Let F be the event that exactly one of A and B occurs, i.e., F =...
write a python program that inputs 10 integer values from the keyboard and then displays their...
write a python program that inputs 10 integer values from the keyboard and then displays their sum. use for loop
write a program that evaluates the following arithmetic expression: ((A+B)/C)*((D-A)+E). Assign test values to the variables...
write a program that evaluates the following arithmetic expression: ((A+B)/C)*((D-A)+E). Assign test values to the variables and display the resulting value.
Write a C program that allows: Three integer values to be entered (read) from the keyboard,...
Write a C program that allows: Three integer values to be entered (read) from the keyboard, Display the sum of the three values on the computer screen as follows: The integers that you have entered are: a b c The sum of a , b & c is ______ Thank you! C Code: Output screen:
Write a c++ program that inputs a time from the console. The time should be in...
Write a c++ program that inputs a time from the console. The time should be in the format “HH:MM AM” or “HH:MM PM”. Hours may be one or two digits. Your program should then convert the time into a four-digit military time based on a 24-hour clock. Code: #include <iostream> #include <iomanip> #include <string> using namespace std; int main() { string input; cout << "Enter (HH:MM XX) format time: "; getline(cin, input); int h, m; bool am; int len =...
Code in C Write a program whose inputs are three integers, and whose outputs are the...
Code in C Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values. Ex: If the input is: 7 15 3 the output is: largest: 15 smallest: 3 Your program must define and call the following two functions. The LargestNumber function should return the largest number of the three input values. The SmallestNumber function should return the smallest number of the three input values. int...
Write a program in C (NOT C++ or C#) The program inputs 5 elements into each...
Write a program in C (NOT C++ or C#) The program inputs 5 elements into each of 2 integer arrays. Multiply corresponding array elements, that is, arrayOne[0] * arrayTwo[0], etc. Save the product into a third array called prodArray[ ]. Display the product array.
Write a C++ program, falling.cpp, that inputs a distance in meters from the user and computes...
Write a C++ program, falling.cpp, that inputs a distance in meters from the user and computes the amount of time for the object falling from that distance to hit the ground and the velocity of the object just before impact. Air resistance is discounted (assumed to fall in a vacuum). To compute the time, use the formula: t = Square Root (2d / g) where d is the distance in meters and g is the acceleration due to gravity on...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT