Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6889881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:12:42+00:00 2026-05-27T06:12:42+00:00

I am completely stumped on this one. I have to utilize the current code

  • 0

I am completely stumped on this one. I have to utilize the current code structure to convert a user-entered hexadecimal value into a decimal value using recursion. The method header for the recursive call cannot be changed. I have this figured out without the use of recursion, but for the life of me cannot wrap my head around how I would do this.

// EDIT — SOLVED

public class hextodecimal {

    public static void main(String[] args) {

        // Test out the parsing with values from page 719
        System.out.println(hexToDecimal("7F"));
        System.out.println(hexToDecimal("FFFF"));
        System.out.println(hexToDecimal("431"));
    }

    public static int hexToDecimal(String hexString) {
        return hexToDecimal(hexString, 0, hexString.length() - 1);
    }

    public static int hexToDecimal(String hexString, int end, int hexLength) {
        if (hexLength < end)
            return 0;
        else {
            int decValue;
        if (hexString.charAt(hexLength) == 'A')
            decValue = 10;
        else if (hexString.charAt(hexLength) == 'B')
            decValue = 11;
        else if (hexString.charAt(hexLength) == 'C')
            decValue = 12;
        else if (hexString.charAt(hexLength) == 'D')
            decValue = 13;
        else if (hexString.charAt(hexLength) == 'E')
            decValue = 14;
        else if (hexString.charAt(hexLength) == 'F')
            decValue = 15;
        else
            decValue = hexString.charAt(hexLength) - '0';

        return hexToDecimal(hexString, end, hexLength - 1) * 16
            + decValue;
        }
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:12:43+00:00Added an answer on May 27, 2026 at 6:12 am

    Only two choices. Process the leftmost char, and pass substring(1) to yourself recursively, or process the rightmost char, and pass what’s to the left to yourself recursively. That should be enough of a hint.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm completely stumped on this one. I have three different lists that need to
I have to admit I am COMPLETELY stumped on this one. I've been scouring
I've been staring at this one for a while and I'm completely stumped. You'll
I am completely stumped as to why this code does not get any SDL
I am completely stumped with this one . . . If I call the
I'm a bit stumped on this one. I had a completely working 2 Node
Regex is absolutely my weak point and this one has me completely stumped. I
A strange one to be honest. I have got this working completely fine on
Really stumped on this one. I have the following PHP file with a variable
This one has me stumped. I have two Windows installations of PHP: 32-bit on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.