Question: Your program will be provided with 3 arguments at the command line. You are required to perform a set of operations over these arguments. These

 Your program will be provided with 3 arguments at the commandline. You are required to perform a set of operations over thesearguments. These operations have been broken up into tasks: the points distributionfor each task and the restrictions (and accompanying deductions) are specified in

Your program will be provided with 3 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 cs280a1.hw1.Operations num 1 num 2 num 3 Task 1: Parse 3 arguments specified as arguments from the command line of the program: one of the arguments will be in decimal, one in binary, and one in hexadecimal. The numbers we specify will be unsigned integers (i.e., the numbers are positive, whole numbers). If an incorrect number of arguments is provided, you should print an error and exit. Task 2: Identify the numbering system that each of the arguments refers to. This should occur regardless of the order in which the numbers are specified. 1. A binary number will have a "0b" prefix. For example, the binary number ob101011001 represents the decimal number 345 2. A hexadecimal number will have a " 0x " suffix. For example, the hexadecimal number 0159 represents the decimal number 345 3. If either prefix " 0b or " 0x has not been specified, then that number should be considered a decimal number. Task 3: Error checking: 1. A binary number should not contain anything other than a 0 or 1. 2. A decimal number should only comprise digits 0 through 9 . 3. A hexadecimal number contains digits 0 through 9 , and letter A through F either in lowercase or uppercase. If any of the above validations fail, print an error and exit. Note: Task 4-8 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 100% ) as outlined in the deductions section. You may use these built in java methods only to validate the correctness of your own implementation. Task 4: 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 nth digit from the right in base b is bn1 Built in java function that you should not use: Integer.parseint (num, radix); Task 5: Compute the 1 s complement (in binary) of every number that was specified at the command line. This will require you to first convert every number into binary. Recall: 1 's complement is accomplished by flipping each bit in the binary representation i.e. a 1 becomes a 0 , and a 0 becomes a 1. Built in java function that you should not use: num Task 6: Compute the 2 s complement (in binary) of every number that was specified at the command line. This will require you to first convert every number into binary. Recall: 2's comp is accomplished by applying 1's comp then adding 1. See lecture slides Built in java function that you should not use: num +1 Task 7: Compute the bitwise OR, AND, and XOR of the 3 numbers. This will require you to first convert every number into binary. Recall: - OR: If either of the values is a 1 the result is a 1 otherwise it is a 0 . - AND: If both values are 1 the result is 1 otherwise it is a 0 . - XOR: If either of the values are 1 and they are not both 1 the value is a 1 otherwise it is a 0 . Built in java function that you should not use: num1 | num 2 , num1 \& num2, num1 num2 Task 8: Compute the bitwise left and right shift of the 3 numbers for 2 shifts. This will require you to first convert every number into binary. Recall: - Left Shift: This is accomplished by appending an x number of 0's. See lecture slides - Right Shift: Accomplished by moving each digit to the right x times. See lecture slides Built in java function that you should not use: num 1>2 2 Example Outputs Notes: - Capitalization and spaces do not matter. - All numbers are printed in the order provided in the arguments. Wrong number of arguments: Command: java cs280a1.hw1.Operations 1 Output: Task 1 Incorrect number of arguments have been provided. Program Terminating! Invalid characters in the specified numbers: Command: java cs280a1.hw1.Operations 15 0b1011 0xhello Output: Task 1 Correct number of arguments given. Task 2 15= Decimal 0b1011= Binary 0 xhello = Hexadecimal Task 3 15= true 0b1011=true 0 xhello = false Example outputs where the program has been provided with the correct arguments leading to a successful run of the program: Command: java cs280a1.hw1.Operations 15 0b1011 0xfa

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!