17.49 Lab: Functions: Number to words Sometimes numbers are converted to words, like in a wedding invitation. So 23 becomes "twenty three". Write a function DigitToWord that takes a single digit number from 0-9 and returns that number's word: 0 is zero, 1 is one, 2 is two, etc (if the number is outside 0-9, return "error"). Write another function TensDigitToWord that takes a single digit number from 2-9, and returns that number's word when it appears in the tens digit: 2 is twenty, 3 is thirty, etc. If the number is outside 2-9, return "error". Finally, write a function TwoDigitNumToWords that takes a two-digit number from 20-99 and returns that number in words. Your main program should get a user's integer, call TwoDigitNumToWords, and output the resulting string. If the input is 23, the output should be "twenty three". Do not do any error checking of the input. Note that your program does not support all numbers. 0-19 will yield error output, for example. HINTS: Write DigitToWord first, and test the function (have your main call that function directly) -- you won't pass any of the tests, but you should still start that way. Next, write TensDigitToWord and test it by itself also. Finally, write TwoDigitNumToWords (calling your first two functions) and test the entire program. Your TwoDigitNumToWords function should pass the ten's digit to TensDigitToWord. To get the tens digit, divide the number by 10. Your TwoDigitNumToWords function should pass the one's digit to DigitToWord. To get the ones digit, mod the number by 10 (num % 10). You can concatenate the strings returned by those two functions using the + operator. Ex: "hello" + " " + "there" yields one string "hello there". The assignment is to find main.cpp In C++ please. Very urgent. Your help is very much appreciated.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

17.49 Lab: Functions: Number to words

 

Sometimes numbers are converted to words, like in a wedding invitation. So 23 becomes "twenty three". Write a function DigitToWord that takes a single digit number from 0-9 and returns that number's word: 0 is zero, 1 is one, 2 is two, etc (if the number is outside 0-9, return "error"). Write another function TensDigitToWord that takes a single digit number from 2-9, and returns that number's word when it appears in the tens digit: 2 is twenty, 3 is thirty, etc. If the number is outside 2-9, return "error". Finally, write a function TwoDigitNumToWords that takes a two-digit number from 20-99 and returns that number in words. Your main program should get a user's integer, call TwoDigitNumToWords, and output the resulting string. If the input is 23, the output should be "twenty three".

Do not do any error checking of the input. Note that your program does not support all numbers. 0-19 will yield error output, for example.

HINTS:

  • Write DigitToWord first, and test the function (have your main call that function directly) -- you won't pass any of the tests, but you should still start that way. Next, write TensDigitToWord and test it by itself also. Finally, write TwoDigitNumToWords (calling your first two functions) and test the entire program.

  • Your TwoDigitNumToWords function should pass the ten's digit to TensDigitToWord. To get the tens digit, divide the number by 10.

  • Your TwoDigitNumToWords function should pass the one's digit to DigitToWord. To get the ones digit, mod the number by 10 (num % 10).

  • You can concatenate the strings returned by those two functions using the + operator. Ex: "hello" + " " + "there" yields one string "hello there".

The assignment is to find main.cpp

In C++ please. Very urgent. Your help is very much appreciated.

17.49 Lab: Functions: Number to words
Sometimes numbers are converted to words, like in a wedding invitation. So 23 becomes "twenty three". Write a function DigitToWord that
takes a single digit number from 0-9 and returns that number's word: 0 is zero, 1 is one, 2 is two, etc (if the number is outside 0-9, return
"error"). Write another function TensDigitToWord that takes a single digit number from 2-9, and returns that number's word when it appears
in the tens digit: 2 is twenty, 3 is thirty, etc. If the number is outside 2-9, return "error". Finally, write a function TwoDigitNum ToWords that
takes a two-digit number from 20-99 and returns that number in words. Your main program should get a user's integer, call
TwoDigitNum ToWords, and output the resulting string. If the input is 23, the output should be "twenty three".
Do not do any error checking of the input. Note that your program does not support all numbers. 0-19 will yield error output, for example.
HINTS:
• Write DigitToWord first, and test the function (have your main call that function directly) -- you won't pass any of the tests, but you
should still start that way. Next, write TensDigitToWord and test it by itself also. Finally, write TwoDigitNumToWords (calling your first
two functions) and test the entire program.
• Your TwoDigitNumToWords function should pass the ten's digit to TensDigitToWord. To get the tens digit, divide the number by 10.
• Your TwoDigitNum ToWords function should pass the one's digit to DigitToWord. To get the ones digit, mod the number by 10 (num %
10).
• You can concatenate the strings returned by those two functions using the + operator. Ex: "hello" +""+ "there" yields one string "hello
there".
Transcribed Image Text:17.49 Lab: Functions: Number to words Sometimes numbers are converted to words, like in a wedding invitation. So 23 becomes "twenty three". Write a function DigitToWord that takes a single digit number from 0-9 and returns that number's word: 0 is zero, 1 is one, 2 is two, etc (if the number is outside 0-9, return "error"). Write another function TensDigitToWord that takes a single digit number from 2-9, and returns that number's word when it appears in the tens digit: 2 is twenty, 3 is thirty, etc. If the number is outside 2-9, return "error". Finally, write a function TwoDigitNum ToWords that takes a two-digit number from 20-99 and returns that number in words. Your main program should get a user's integer, call TwoDigitNum ToWords, and output the resulting string. If the input is 23, the output should be "twenty three". Do not do any error checking of the input. Note that your program does not support all numbers. 0-19 will yield error output, for example. HINTS: • Write DigitToWord first, and test the function (have your main call that function directly) -- you won't pass any of the tests, but you should still start that way. Next, write TensDigitToWord and test it by itself also. Finally, write TwoDigitNumToWords (calling your first two functions) and test the entire program. • Your TwoDigitNumToWords function should pass the ten's digit to TensDigitToWord. To get the tens digit, divide the number by 10. • Your TwoDigitNum ToWords function should pass the one's digit to DigitToWord. To get the ones digit, mod the number by 10 (num % 10). • You can concatenate the strings returned by those two functions using the + operator. Ex: "hello" +""+ "there" yields one string "hello there".
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education