COP3502 – Solved

$ 20.99
Category:

Description

Submission Format
Assignment
Problems
Implement the class HW2. The class will contain these structural elements and functionality. Sample output is given below. Your output must look exactly like this output.

Structure: Properties
• One private property of type char logicSelection, the user’s currently selected logical operation.
• One private property of type int total, the total number of operations performed. Each time any operation is selected, increment the counter keeping track of the total number of all the operations the user has performed.

Structure: Methods
• The elements / list of methods we include in every class.
• The method printMenu(): this method prints the menu of available operations. Note, the method does not handle receiving a user selection, it merely displays menu information.
• The method makeLogicSelection(char logicSelection): this method set the logic selection to either ‘a’/’A’ for the logical AND [ && ] or ‘b’/’B’ for the logical OR [ || ]. In your solution, ensure the user has selected a valid option [either (a) or (b)]. If not, print an error message and do not modify the previous selection made.
• The method performLogic(boolean operand1, boolean operand2, boolean negation): the method will receive two boolean values and calculate the result of the two boolean values when used with the selected logical operator [either AND or OR]. If true is passed in as the negation parameter, then a logical negation will precede the entire logical operation.
• The method printTruthTable(): this method will print the truth table of the selected operation. For example, if Logical AND has been selected, print the entire truth table of the logical AND.
• The method moduloRange(int modValue): this method will print the remainder range possible from a given modValue.

Output
When calling each method [right clicking on the method in BlueJ] here is the output produced by each method:

Operation Menu

Logic Selections:
(a) Logical AND (&&) (b) Logical OR (||)

Methods:
Make Logic Selection
Modulo Range
Perform Logic
Print Truth Table

Perform Logic

Operation #1

Logic Selection: a
Operand #1: true
Operand #2: true
Negation: false

(true && true) yields true

Operation #2

Logic Selection: a
Operand #1: true
Operand #2: false
Negation: true

!(true && false) yields true

//… and so on

Print Truth Table

Operation #3

A B (A && B)
—————-
T T T
T F F
F T F
F F F

Module Range

Operation #4

Mod Value: 8
Start of Range: 0
End of Range: 7

Print Info

Operation Information…
Logic Selection = a Total Operations = 4

Reviews

There are no reviews yet.

Be the first to review “COP3502 – Solved”

Your email address will not be published. Required fields are marked *