Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Complete the following function, max_consecutive_hex_digits, so that it returns

ID: 3791325 • Letter: C

Question

Complete the following function, max_consecutive_hex_digits, so that it returns the maximum number of consecutive run of hex digit and the hex digit in the unsigned long long variable (64 bits) on TM4C123 that is passed to it. If there is a tie, return any ONE of the hex digit in the tie. Note - You may not change the function definition signature (prams and return type). You may have to pack/encode/interpret the result in the unsigned char return value. For example, in the unsigned long long number 0xFFF4 8 OFF FFF5 F123, 'F' occurs 5 times consecutively in the hex representation of unsigned long long number 0xFFF4 8OFF FFF5 F123. unsigned char max_consecutive _hex_digits (unsigned long long x) {//YOUR CODE HERE

Explanation / Answer

unsigned char max_consecutive_hex_digits(unsigned long long x)

   {

  
       String num1=x.replaceAll("\s+", "");

       int len,maxCount=0,count=1;
       len=num1.length();
for(int i=1;i<len;i++)
       {
           if((num1.charAt(i)==num1.charAt(i-1)) && ((num1.charAt(i)>='a' && num1.charAt(i)<='f')||(num1.charAt(i)>='A' && num1.charAt(i)<='F')))
           {
               count++;
           }
           else
           {
               maxCount=Math.max(maxCount, count);
               count=1;
           }
       }
       return maxCount;
   }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote