Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 Description of Task As part of this assignment, you will be responsible for conversions between number representations and bitwise manipulations. The programming assignment should
Description of Task
As part of this assignment, you will be responsible for conversions between number representations and
bitwise manipulations. The programming assignment should be developed in Java, and your classes
must reside in the package cshw
Your program will be provided with arguments at the command line. You are required to perform a
set of operations over these arguments. These operations have been broken up into tasks: the points
distribution for each task and the restrictions and accompanying deductions are specified in the
grading section of this assignment.
Command line execution: java cshwOperations Task :
Error checking:
A binary number should not contain anything other than a or
A decimal number should only comprise digits through
A hexadecimal number contains digits through and letter A through either in lowercase
or uppercase.
Print true or false for every input and terminate if any are false. You should print all regardless of any
input being invalid.
Note: Task can be completed using built in java methods. Only use them to check your
answer. If you violate these restrictions, points will be deducted up to as outlined in
the deductions section. You may use these built in java methods only to validate the
correctness of your own implementation.
Task :
Convert each of the input numbers into the corresponding number in other numbering systems. For
example, if the number is in binary, you should convert that number into their corresponding
representations in the decimal and hexadecimal numbering systems.
Recall: The digit from the right in base is
Built in java function that you should not use: Integer.parseInt num radix;
Task :
For every number specified at the command line, you will compute that number's negative
representation in s complement. For example, if we give you you will return represented in s
complement. This will require you to first convert each of the input numbers into binary.
Recall: s complement is accomplished by flipping each bit in the binary representation ie a becomes
a and a becomes a
Built in java function that you should not use: num
Task :
For every number specified at the command line, you will compute that number's negative
representation in s complement. For example, if we give you you will return represented in s
complement. This will require you to first convert every number into binary. You can ignore any potential
overflow, meaning if we give you a bit bitstring, you should return a bit bitstring.
Recall: s comp is accomplished by applying s comp then adding
Built in java function that you should not use: num
Task :
Compute the bitwise OR AND, and XOR of the numbers. This will require you to first convert every
number into binary. This will require that you have equal length bitstrings. Recall that frontpadding
with s does not change the value of an unsigned binary number, so you can frontpad all binary
bitstrings with before operating such that all binary numbers are the same length as the longest
one. Recall:
OR: If either of the values is a the result is a otherwise it is a
AND: If both values are the result is otherwise it is a
XOR: If either of the values are and they are not both the value is a otherwise it is a
Built in java function that you should not use: num num num & num num num
Task :
Compute the bitwise left and right shift of the numbers for shifts. This will require you to first convert
every number into binary.
Recall:
Left Shift: This is accomplished by appending an x number of s The output will be longer
than the input.
Right Shift: Accomplished by moving each digit to the right times. The output binary string
will be shorter than the input. See lecture slides
Built in java function that you should not use: num num
Deduction:
There is a point deduction ie you will have a zero on the assignment if you:
Build a GUI
Use of the following methods will result in a deduction of the task points where used:
Integer.parse
Integer.toHexString
Integer.toBinaryString
Built in bitwise operations ~ &
a Note: Logical operations are allowed && etc.
A deduction will occur from using any of the methods in this list and all their overloaded
variants Please note that Integer.parse refers to Integer.parseInt. An additional set of overloaded
methods has been included to the deductions list from the Integer class: Integer.value
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started