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

Can someone help me out with this please? i need to write a program that takes a

ID: 3620822 • Letter: C

Question

Can someone help me out with this please? i need to write a program that takes an input from the user that has a value from minimum 0 and maximum of 99,999.99. The program should then do two things. It should post the number back, including the comma in 1,000 and decimal even if the number is 1,000.00. The second thing the program should do is write the exact number out in words and the decimal in fraction. For example
input: 10
output:
1. ****10.00
2. ten

input: 12345.66
output:
1. 12,345.66
2. twelve thousand three hundred fourty five and 66/100

input: 987.65
output:
1. ***987.65
2. nine hundred eighty seven and 65/100

If the numbers do not occupy nine spaces including comma decimal as in the case with every number over 10,000.00 then the program should input an asterisk (*) to signify that a blank space. for example 9,999.99 would be *9,999.99.

Thanks for your help!

Explanation / Answer

please rate - thanks #include <stdio.h>
#include <conio.h>
int main()
{char numbers[20][10]={"zero","One","Two","Three","Four","Five","Six","Seven","Eight",
                    "Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen",
                    "Sixteen","Seventeen","Eighteen","Nineteen"};
char tens[9][9]={"Twenty ","Thirty ","Forty ","Fifty ","Sixty ","Seventy ","Eighty ","Ninty "};
char amount[11],num[10]="******.**";
char stars[7][7]={"","*","**","***","****","*****","******"};
int last=-2;
int dot=-1,comma=-1,j, i,cents, digits,number,decimal,temp,pow[6]={1,10,100,1000,1000,100000};
printf("How much is the check for? ");
scanf("%s",&amount); //get the amount
for(i=0;i<=10;i++)   // look for the dot
   if(amount[i]=='.')
      {dot=i;     //save it's position
         break;
       }

if(dot==-1)
   {  
     for(i=0;amount[i]!='';i++);
        amount[i+3]='';
      amount[i+2]='0';
      amount[i+1]='0';
      amount[i]='.';  
      dot=i;  
    }

if(dot>3)
     {num[2]=',';
      comma=2;
      }
j=7;
for(i=dot+1;i<=dot+2;i++)
     num[j++]=amount[i];
num[6]='.';
j=5;  
for(i=dot-1;i>=0;i--)     // get amount before .
   {if(j==2&&comma==2)
        j--;
    num[j--]=amount[i];
    }
for(i=0;i<9;i++)
printf("%c",num[i] );
printf(" ");      



digits=dot;

//change number to decimal
decimal=0;
for(i=0;i<digits;i++)
    decimal=decimal*10+amount[i]-48;
   temp=pow[digits-1];

for(i=digits;i>=1;i--)
   {
   number=decimal/temp;
    decimal=decimal%temp;
    temp=temp/10;
     {
       
        switch(i)
          {
           case 4:printf("%s",numbers[number]);       
                printf(" Thousand ");
                break;
           case 5:if(number<=19)               
                      printf("%s",numbers[number]);
                  else
                    {printf("%s",tens[(number/10)-2]);
                     if(number%10!=0)
                       printf("%s",numbers[(number)%10]);
                       }
                printf(" Thousand ");
                i--;              //don't do next digit
                 break;
                 case 6: temp=temp/10;          //100,000 ; do next 2 digits as 1
                 case 3:
                 printf(numbers[number]);
                 printf(" hundred ");
                 last=0;
                 break;
           case 2:                  //done
                  if(number>1)
                    {printf("%s",tens[number-2]);
                     if(decimal==0)              //last digit 0 done
                       i--;
                    break;
                   }
                  else
                    {if(last<0)
                        printf("%s",numbers[number*10+decimal]);
                    i--;                //done
                    if(last<0)
                        last=-1;
                    break;
                    }
           case 1:
                      printf("%s",numbers[number]);
               
                 break;
          }
          }
    
     }
printf(" and ");
for(i=dot+1;i<=dot+2;i++)     //get cents
    printf("%c",amount[i] );
    printf("/100 ");
getch();
return 0;
}


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