Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA: Write a recursive method that converts a decimal number into a hex number as a string. The method header is: public static String dec2Hex(int

JAVA:

Write a recursive method that converts a decimal number into a hex number as a string. The method header is:

public static String dec2Hex(int value)

--

Write a recursive method that parses a binary number as a string into a decimal integer. The method header is:

public static int bin2Dec(String binaryString)

--

Write a recursive method that parses a hex number as a string into a decimal integer. The method header is:

public static int hex2Dec(String hexString)

--

Write a recursive method to print all the permutations of a string. For example, for the string abc, the permutation is:

abc acb bac bca cab cba

--

Define the following two methods. The second is a helper method.

public static void displayPermutation(String s)

public static void displayPermutation(String s1, String s2)

The first method simply invokes displayPermutation( , s). The second method uses a loop to move a character from s2 to s1 and recursively invokes it with a new s1 and s2. The base case is that s2 is empty and prints s1 to the console.

--

Write a menu driven test program that prompts the user to choose which of your methods to test out or to exit. The user is then to enter his/her choice:

1. In the case of string permutation they enter a string and the program displays all its permutations, then returns to the menu.

2. In the case of the hex the user enters a hex string and the program displays its decimal equivalent, then returns to the menu.

3. In the case of the binary the user to enters a binary string and the program displays its decimal equivalent, then returns to the menu.

4. In the case of the decimal the user to enters a decimal number and the program displays its hex equivalent, then returns to the menu.

5. Boundary, recursive programs can quickly get out of hand complexity wise, Prompt the user at the start of your program to set an upper bound on input size, warm them of time delay in case of large inputs (say greater than 6 digits or chars).

6. In the case of exit, display how much time elapsed and the number of recursive calls per function requested (bonus 1 point), then the program is to exit without leaking any resources...

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions

Question

=+2 How does the preparation and support for each type of IE vary?

Answered: 1 week ago