Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The programmers of a TTS (text-to-speech) program have discovered that their product does a poor job of reading numbers written in conventional numeric form. Currently,

image text in transcribed

The programmers of a TTS (text-to-speech) program have discovered that their product does a poor job of reading numbers written in conventional numeric form. Currently, it just announces each digit in the number, one after the other, which gets confusing to the listener after a few digits have gone by. They would prefer to have a more natural reading of numbers, and one of them has suggested that, if they convert numeric strings into the appropriate text equivalent, e.g., convert "1023" into "one thousand and twenty three", then their speech engine will be able to handle the reading with no further modification. Write a program to carry out the transtormation of non-negative integers into conventional English wording: English has unique names for the numbers 0-19: "zero". "one". "two", "three", "four". "five",-six" "seven", "eight, "nine", "ten, "eleven,"twelve", "thirteen", "fourteen, "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" . The subsequent multiples of 10 are named "twenty", "thirty", "forty", "fifty", "sixty", "seventy "eighty" "ninety" The combination of one of those multiples often with a digit 1-9 is always hyphenated: e.g., 31 => e, 77 seventy-severn . Multiples of 100 are counted 1-9 and set off from any following non-zero digits by 'and: e.g., 200 -> "two hundred, 412-"four hundred and twelve, 777 "seven hundred and seventy-seven . Thousands and milions are counted off using the above rules to form numbers 1-999, and are set off from any non-zero rnder by a comma: e.g., 1,253,101"one millin, two hundred and fifty- three thousand, one hundred and one If a nurmber with a non-erripty thousands or millions component is followed by a remainder of 1-99 then instead of a comma the parts are separated by "and": e.g., 1,000,011"one million and eleven", 20,222,043twenty mlion, two hundred and twenty-two thousand and forty-three Input Format Input will consist of one or more datasets. Each dataset will consist of a single line containing a non- negative integer in the range 0..999,999,999. Although we have used commas within digit strings for clarity in this problen description, there will be no commas in the input. There will be no leading zeros on positive input numbers. A line with a negative value signals the end of input. Output Format For each dataset, print a single ne containing the spelled out equivalent of the number, according to the rules above Formatting requirements: . The output must be left-justified All alphabetic characters must be in lower-case. .Exactly one blank must separate adjacent words, except when a hyphen or comma is called for . When a comma is used, i must be followed by exactly one blank. when a hyphen is used, no blank space appears to either side of the hyphen. Sample Input 0 222143 000001 -1 Sample Output 0 two hundred and twenty-two thousend, one hundred and forty-three onc million and orc

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

How does a multiport repeater / hub function on a network?

Answered: 1 week ago

Question

Explain all drawbacks of the application procedure.

Answered: 1 week ago

Question

Determine Leading or Lagging Power Factor in Python.

Answered: 1 week ago