The text entered will be a string of Alphanumeric Words with

The text entered will be a string of Alphanumeric Words without punctuation, except for spaces between any adjacent Alphanumeric Words and a single period as the final character. Alphanumeric Words, if present, consist of only Uppercase Letters {A,B,C, ... , Z} and/or Numeric Digits {0,1,2, ... , 9}. If and only if an entire Alphanumeric Word is a valid hexadecimal value, then it will be replaced with its equivalent decimal value. The program shall output the text with the corresponding substitutions to the console.

Also, determine the largest valid hexadecimal value that is an entire Alphanumeric Word present in the string. Based on that value, determine the corresponding range in the left-hand column. Finally, output the String Digit Score listed in the right-hand column as a new line to the console. Table 1: Mapping of String Digit Score.

Value of largest Hex utterance in sentence

>=0 and = or no valid Hex word present

Sparse

>=100hex and <=FFFFhex

Intermediate

>=10000 hex and

Plentiful

Consider sample input: I ACED THE EXAM AND EARNED AN A PLUS.

Value of largest Hex utterance in sentence

| String Digit Score

>=0 and = or no valid Hex word present

Sparse

>=100hex and <=FFFFhex

Intermediate

>=10000 hex and

Plentiful

Solution

#include<stdio.h>
#include<stdlib.h>
#include <math.h>
int main()
{
while(1)
{
   char a[100],b;
   printf(\"Enter the sentence\ \");
   int i,f=0,j;
   while(1)
   {
   i=0;
   f=0;
   int temp=0,max=0;
   while((b=getchar())!=\' \')
   {
       if (b==\'\ \' ||b==\'.\')
           break;
       if (f==0 && b>\'F\')
           f=1;
       a[i++]=b;
   }
   if(f==0)
   {
       for (j=i-1;j>=0;j--)
       {
           int xx;
           if (a[j]>=\'0\' && a[j]<=\'9\')
           xx=a[j]-\'0\';
           else if(a[j]>=\'A\' && a[j]<=\'F\')
           xx=a[j]-\'A\'+10;
           temp+=xx*pow(16,i-1-j);
       }
       printf(\"%d\",temp);
       if(temp>max)
           max=temp;
   }
   else
   {
       for (j=0;j<i;j++)
           putchar(a[j]);
   }
   putchar(b);
   if(b==\'\ \')
   {
       if(max==0)
           printf(\"Sparse\ \");
       else if(max>=3200 && max<=69904)
           printf(\"Intermediate\ \");
       else
           printf(\"Plentiful\ \");
       printf(\"Enter the sentence\ \");
   }
   }
}
return 0;
}


Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site