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

Write a program that will prompt the user to enter an integer between 0 and 999,

ID: 3634668 • Letter: W

Question

Write a program that will prompt the user to enter an integer between 0 and 999, and then print out the English phrase that represents this number. A sample dialog might be:
Enter an integer between 0 and 999: 375
This number in English is three hundred seventy five

The bulk of this program should be a function
void numToEnglish(unsigned int num, char english[]);
The function fills the array english with the string that represents the number num.

Hints. You might find the following arrays of string literals useful:

char* first20[] = {“zero”, “one”, “two”, “three”, “four”, “five”,
“six”, “seven”, “eight”, “nine”, “ten”, “eleven”, “twelve”, “thirteen”, “fourteen”, “fifteen”, “sixteen”, “seventeen”, “eighteen”,
“nineteen”};
char* tens[] = {“twenty”, “thirty”, “forty”, “fifty”, “sixty”,
“seventy”, “eighty”, “ninety”};

I have an idea with how to start it but I'm stuck from there.

"void numToEnglish(unsigned int num, char english[]);
main()
{
char* first20[] = {"zero", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "ten", "eleven",
"twelve", "thirteen", "fourteen", "fifteen", "sixteen",
"seventeen", "eighteen","nineteen"};
char* tens[] = {"twenty", "thirty", "forty", "fifty", "sixty",
"seventy", "eighty", "ninety"};

printf("Enter an integer between 0 and 999: ");
scanf("%s",s1);
printf("This number in English is &s",s1);
}"

Any ideas guys? I successfully made a working version of this but it doesn't uses arrays like I'm supposed to. This is due tomorrow and yet I have to study for midterm tomorrow as well! Thank you in advance to whoever helps me out with this. And of course, I'll rate.

Explanation / Answer

codes in java, u have to try and understand and code it in the language you required. // scan in the numbers, eg:375 int number = sc.nextInt(); //get the first number, eg:3 int first = number/100; //get the last 2 numbers, eg:75 number = number %100; //get the number in the middle, eg:7 int second = number/10; //get the last number:eg: 5 int third = number%10; //process the first number, output result only if first number is between 1 and 9. if(first != 0){ String out = first20[first]; } //process the middle number. if(second == 1){ third = 10 + third; out = out + first20[third]; } else if (second == 0){ out = out + first20[third]; } else { out = out + tens[second] + first20[third]; } System.out.printf("This number in English is %s", out);

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