473,387 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Have to make truth tables

ok taking computer science class anybody know what to do i am not computer literate

CoSc 111.003 Spring 2008 Assignment 4

1) Each student shall design, develop, code, test and submit an
Original computer program which uses a function or functions to display the TRUTH TABLES for the Logical And, the Logical Or, and the Logical Not operators., as defined in Section 5.8, of the text, 5Th/6Th Edition.
2) The program shall:

a) Use a function to display the Logical And Truth Table, and
b) Use a function to display the Logical Or Truth Table, and
c) Use a function to display the Logical Not Truth Table, and
d) The main application program shall be prompt the user to choose which Truth Table to display, and
e) The main application program shall operate in a loop which allows the user to choose the Truth Tables , until the user signals to ‘Terminate’ the program, and
f) The main application program shall provide:
. A User friendly interface
. An interactive user interface, with
. Only keyboard and display as I/O devices
Mar 5 '08 #1
6 11416
Parul Bagadia
188 100+
ok taking computer science class anybody know what to do i am not computer literate

CoSc 111.003 Spring 2008 Assignment 4

1) Each student shall design, develop, code, test and submit an
Original computer program which uses a function or functions to display the TRUTH TABLES for the Logical And, the Logical Or, and the Logical Not operators., as defined in Section 5.8, of the text, 5Th/6Th Edition.
2) The program shall:

a) Use a function to display the Logical And Truth Table, and
b) Use a function to display the Logical Or Truth Table, and
c) Use a function to display the Logical Not Truth Table, and
d) The main application program shall be prompt the user to choose which Truth Table to display, and
e) The main application program shall operate in a loop which allows the user to choose the Truth Tables , until the user signals to ‘Terminate’ the program, and
f) The main application program shall provide:
. A User friendly interface
. An interactive user interface, with
. Only keyboard and display as I/O devices
I guess you should try at least something; its not that tough,
infact its bit easy.
First of all just make a menu driven main function.
then make different functions; one for each logic operation; and u just have to display the table right?
So u dont even have to apply a logic for performing different operations.
Simply write a code for dislaying it.
Try it out.
Mar 5 '08 #2
MACKTEK
40
Here's some info on truth tables
http://en.wikipedia.org/wiki/Truth_table

Here's the basics on how to write a very simple program:
http://www.engin.umd.umich.edu/CIS/course.des/cis400/cpp/hworld.html

The hello world program gets you started.
Things you will want to add to it are:
A method to prevent your console application from closing as soon as you execute it.
try searching google for "cin"

That should get you started...
then it would be a matter of:
using cout to give the "options"
and using cin to get the choices...

Try also doing a search for begginers C++ that will help.
Mar 6 '08 #3
thanks everybody i will be back if i have some more problems after trying it
Mar 6 '08 #4
thanks everybody i will be back if i have some more problems after trying it
i have the truth tables but what function would I use to tell the user to pick one truth table and only display that truth table i was thinking the if but not sure exactly what to do
Mar 7 '08 #5
Ganon11
3,652 Expert 2GB
You can have a function that will display a menu - something like:
Expand|Select|Wrap|Line Numbers
  1. Press 1 for option A,
  2. Press 2 for option B,
  3. Press 3 for option C,
  4. Press Q to quit.
It will then get input from the user and, depending on which was entered, execute option A, B, or C, quit, or inform the user that an invalid choice was made.
Mar 7 '08 #6
My program isn't working I think I am using the void wrong. The compile log said this, and the rest is my program

I tried to do this as a function but I could not figure out why the void or was not working. It would not compile
/*Compiler: Default compiler
Executing g++.exe...
g++.exe "E:\COSC\Exercises\Banks_Asgn4_redo.cpp" -o "E:\COSC\Exercises\Banks_Asgn4_redo.exe" -g3 -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -g3
E:\COSC\Exercises\Banks_Asgn4_redo.cpp:26: error: expected init-declarator before "void"
E:\COSC\Exercises\Banks_Asgn4_redo.cpp:26: error: expected `,' or `;' before "void"

Execution terminated */


// Asgn4.cpp
// Ashley Banks
// March 4,2008
// 2:35 pm
// Program that uses function to display
// truth tables for the Logical And,
// Logical Or, and Logical Not operators

#include <iostream>
using std::cout; // outputs data
using std::endl; // endline
using std::cin; //inputs data
using std::boolalpha; // causes bool values to print as "true" or "false"
void AND ()
void OR ()
void NOT ()

// program has to display truth table at user's will and loop until user quits
int main()

{
int a, b; // variables to store user input

do {
cout << "Choose one truth table to display:";
cin >> a; // input for truth table to display
if ( a == 1)
AND ();
// if user chooses 1 display logical and truth table

if ( a == 2)
OR ();
// if user chooses 2 display logical or truth table

if ( a == 3 )
NOT ();
// if user chooses 3 display logical not truth table

// loop until user quits
cout<<"Do you want to quit? Press 1 to quit or 0 to display another truth table \n";
cin>>b; // input answer for continuance
cout<<endl;
} while ( b!= 1 ); // input of one needed to terminate

return 0; // indicate successful termination
}

void AND()
{
// create truth table for && (logical AND) operator
// make function
cout << boolalpha << "Logical AND (&&)"
<< "\nfalse && false: " << ( false && false )
<< "\nfalse && true: " << ( false && true )
<< "\ntrue && false: " << ( true && false )
<< "\ntrue && true: " << ( true && true ) << "\n\n";
}
void OR ()
{
// create truth table for || (logical OR) operator
// make function
cout << boolalpha << "Logical OR (||)"
<< "\nfalse || false: " << ( false || false )
<< "\nfalse || true: " << ( false || true )
<< "\ntrue || false: " << ( true || false )
<< "\ntrue || true: " << ( true || true ) << "\n\n";
}
void NOT ()
{
// create truth table for ! (logical negation) operator
cout << boolalpha << "Logical NOT (!)"
<< "\n!false: " << ( !false )
<< "\n!true: " << ( !true ) << endl;
cout <<"\n";
}
Mar 17 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Robertf987 | last post by:
Hi, I'm a bit stuck with an access database. I'm using access 2000 if that's any help. Right, it's 3:40am right now and I'm rather tired, but I *hope* this makes sense. I have a table which...
1
by: rejoybhaskar | last post by:
guys, please tell meif it is possible to make 2 tables on the same horizontal line without using css.. i meam if i use float:left for one and float:right for one basically one comes below the other.....
12
by: Gozil | last post by:
I have seen some really smooth motion created with javascript, like w3c's new design: http://validator.w3.org/ Im just wondering how its possible to do this and if someone could recommend me some...
6
Nathan H
by: Nathan H | last post by:
Is there a way to make it so Access does not create an import errors table if there are problems? I am handling import errors via another method, but these tables being auto generated are causing...
2
by: hazahafiz | last post by:
i want to make transaction tables to store transaction payment between buyer tables and seller tables. the transaction tables include...
5
by: andrea | last post by:
Well I would like to make a little program that given a certain logical expression gives the complete truth table. It's not too difficult in fact, I just have some doubts on how to design it. ...
6
by: Michael D | last post by:
I want to create a different table for each sales person listed in a table. If I have salesperson1 through salespersonN listed in the table, I'd like to end up with a table for salesperson1 with just...
7
by: papacologne | last post by:
Given the truth values of the propositions p and q, display the truth values of the conjunction, disjunction, exclusive or, conditional statement, and biconditional of these propositions. Can you...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.