Question: In java Partl: Binary Print Write a recursive method that prints the binary form of a given non-negative integer, with the following specification: public class
Partl: Binary Print Write a recursive method that prints the binary form of a given non-negative integer, with the following specification: public class NPrintf public static void binaryPrint (int n) t I/ your implementation The method prints the value of n as a BINARY number. If n is zero, then a single zero is printed; otherwise no leading zeros are printed in the output. Examples: n-0 Output:0 n-4 Output:100 n-27 Output:11011 Hint: How to convert an int to its binary form? A very intuitive way is to divide the number by 2 in each recursion. In each recursive call, you print either 0 (unless it is a leading zero) if 2 divides n, or'' otherwise. Part2: Evaluate Arithmetic Expressions Requirements 1. Implement a concrete ArrayStack class that extends the Stack interface as we discussed in the class (any other different Stack class implementation, even if it is i yourself, will not receive any credit). 2. Write a method that evaluates an arithmatic expression, which is given by a string. public class Evaluate t public static int expression (String str)( // return the value 3. Your implementation is required to use the Stack interface we discussed in the class. 4. Write a necessary test program to verify the result. For example, 14-3 4+2 5-6 2 (should return 0) You may want to test all possible corner conditions to make sure your implement is inclusive parentheses. examples: 5. Your implementation only considers+ and * operators and does not need to consider 6. Bonus: extra 10 points will be awarded if you implementation supports parentheses. For 14-3* (4+2 (5-6))*2 (should return 2) Submission 1. Each student submits one copy of the source code: NPrint.java, Evaluate java, Stack.java and ArrayStack.java. Please also provide the corresponding test programs
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
