/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} Problem 45 (Writing the Word Equivalent of ... [FREE SOLUTION] | 91Ó°ÊÓ

91Ó°ÊÓ

(Writing the Word Equivalent of a Check Amount) Continuing the discussion of the previous example, we reiterate the importance of designing checkwriting systems to prevent alteration of check amounts. One common security method requires that the check amount be both written in numbers and "spelled out" in words. Even if someone is able to alter the numerical amount of the check, it is extremely difficult to change the amount in words. Write a program that inputs a numeric check amount and writes the word equivalent of the amount. Your program should be able to handle check amounts as large as $99.99. For example, the amount 112.43 should be written as ONE HUNDRED TWELVE and 43/100

Short Answer

Expert verified
Convert the check amount into word equivalent and cents as a fraction of 100.

Step by step solution

01

Understand the Problem

The task is to convert a numeric check amount (up to $99.99) into its equivalent word form. The major part of the amount (before the decimal) should be written in words, while the decimal part should be expressed as a fraction of a hundred.
02

Identify Number Ranges

The program needs to handle two significant parts: numbers from 0 to 99 before the decimal and two-digit numbers after the decimal (cents). Specific terms like 'HUNDRED', and numbers 1 to 19, and multiples of ten (20, 30, ..., 90) need to be mapped to their word equivalents.
03

Create Number Conversions

For numbers 1 to 19, associate each with its word equivalent (e.g., 1 - 'ONE', 2 - 'TWO'). Similarly, for tens (20, 30, ..., 90), create a list that includes these in word form (e.g., 20 - 'TWENTY'). This will include the basic building blocks for larger numbers.
04

Decompose Numbers into Words

For amounts below 100, break down numbers into tens and units to convert into words. For example, '56' should be translated to 'FIFTY SIX' by combining 'FIFTY' (from tens) and 'SIX' (from units).
05

Format the Check Amount

Combine the word equivalent of the integer part of the check amount with the fraction representing cents. For example, if the amount is 43, it should be displayed as 'FORTY THREE and 43/100'.
06

Compose the Full Check Amount in Words

For amounts involving hundreds (e.g., 112), convert and combine word equivalents, adding 'HUNDRED' as needed. Example: '112' becomes 'ONE HUNDRED TWELVE'. Ensure the output includes both parts: 'ONE HUNDRED TWELVE and 43/100'.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with 91Ó°ÊÓ!

Key Concepts

These are the key concepts you need to understand to accurately answer the question.

Checkwriting Systems
Checkwriting systems play a crucial role in maintaining the security and integrity of financial transactions. This is achieved by utilizing a dual-format system in which check amounts are displayed both numerically and in written words. This method helps prevent any unauthorized changes, as it is quite challenging for someone to alter not only the numbers but also their spelled-out equivalent. This dual-format approach ensures that recipients and banks recognize any discrepancies and can address them promptly. The blending of numerical and written forms acts as a deterrent against potential fraud, offering more peace of mind to both the issuer and receiver.
Number to Words Conversion
Number to words conversion is a fundamental task within checkwriting systems. It involves transforming a numerical value into a corresponding set of words, which is essential for visually confirming the intended amount. This process is highly beneficial as it adds an additional layer of verification.
To effectively convert numbers into words, one must consider:
  • Numbers from 1 to 19, each having unique word equivalents like 'ONE', 'TWO', etc.
  • Multiples of ten such as 'TWENTY', 'THIRTY', etc., up to 'NINETY'.
  • The use of 'HUNDRED' for hundreds places to articulate larger numbers.
Combine these elements logically to create word representations. For instance, the number 56 translates into 'FIFTY SIX' by combining 'FIFTY' and 'SIX'. This conversion is also applied to amounts involving decimals, displaying them as a fraction of a hundred, such as '43/100'.
C++ Programming
In C++ programming, implementing the conversion of numbers to words involves utilizing arrays or switch-case statements to map numbers to their corresponding words. C++ is particularly well-suited for this task due to its robust handling of arrays and logical flow control.
C++ provides the tools needed to:
  • Decompose a number into its constituent parts: hundreds, tens, and units.
  • Iterate through these parts using loops, ensuring each part is translated correctly.
  • Convert and print each numerical segment sequentially, followed by formatting the decimal as a fraction of 100.
By handling these manipulations effectively, a C++ program can accurately translate figures like 112.43 into 'ONE HUNDRED TWELVE and 43/100', preserving the integrity of the checkwriting system.
Algorithm Design
Designing an algorithm to convert numbers to words requires a structured approach. A successful algorithm efficiently breaks down a numerical value into understandable segments and converts each segment into its word equivalent.
Essential steps in the algorithm design include:
  • Identifying the number range, ensuring that the algorithm can handle both the units and tens effectively.
  • Mapping individual numbers to words through data structures such as arrays or dictionaries, which store known values for easy access.
  • Incorporating logical structures—like loops and conditional statements—to manage different numerical scenarios, especially those involving numbers in the tens and hundreds brackets.
With this thought-out methodology, the algorithm ensures reliable and repeatable conversions from numbers like 112 into word forms such as 'ONE HUNDRED TWELVE'. This approach not only reinforces the security in financial processes but also enhances the user experience by providing clarity and consistency.

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

For each of the following, write a single statement that performs the specified task. Assume that long integer variables value1 and value2 have been declared and value1 has been initialized to 200000. a. Declare the variable longPtr to be a pointer to an object of type long. b. Assign the address of variable value1 to pointer variable longPtr. c. Print the value of the object pointed to by longPtr. d. Assign the value of the object pointed to by longPtr to variable value2. e. Print the value of value2. f. Print the address of value1. g. Print the address stored in longPtr. Is the value printed the same as value1's address

Perform the task specified by each of the following statements: a. Write the function header for a function called exchange that takes two pointers to double-precision, floating-point numbers x and y as parameters and does not return a value. b. Write the function prototype for the function in part (a). c. Write the function header for a function called evaluate that returns an integer and that takes as parameters integer x and a pointer to function poly. Function poly takes an integer parameter and returns an integer. d. Write the function prototype for the function in part (c). e. Write two statements that each initialize character array vowel with the string of vowels, "AEIOU".

Perform the task specified by each of the following statements: a. Write the function header for function zero that takes a long integer array parameter bigIntegers and does not return a value. b. Write the function prototype for the function in part (a). c. Write the function header for function add1AndSum that takes an integer array parameter oneTooSmall and returns an integer. d. Write the function prototype for the function described in part (c)

(Check Protection) Computers are frequently employed in check-writing systems such as payroll and accounts-payable applications. Many strange stories circulate regarding weekly paychecks being printed (by mistake) for amounts in excess of \(1 million. Weird amounts are printed by computerized check-writing systems, because of human error or machine failure. Systems designers build controls into their systems to prevent such erroneous checks from being issued. Another serious problem is the intentional alteration of a check amount by someone who intends to cash a check fraudulently. To prevent a dollar amount from being altered, most computerized check-writing systems employ a technique called check protection. Checks designed for imprinting by computer contain a fixed number of spaces in which the computer may print an amount. Suppose that a paycheck contains eight blank spaces in which the computer is supposed to print the amount of a weekly paycheck. If the amount is large, then all eight of those spaces will be filled, for example, 12345678 (position numbers) On the other hand, if the amount is less than \)1000, then several of the spaces would ordinarily be left blank. For example, 99.87 \-------- 12345678 contains three blank spaces. If a check is printed with blank spaces, it is easier for someone to alter the amount of the check. To prevent a check from being altered, many check-writing systems insert leading asterisks to protect the amount as follows: ***99.87 \-------- 12345678 Write a program that inputs a dollar amount to be printed on a check and then prints the amount in check-protected format with leading asterisks if necessary. Assume that nine spaces are available for printing an amount.

For each of the following, write C++ statements that perform the specified task. Assume that double-precision, floating-point numbers are stored in eight bytes and that the starting address of the array is at location 1002500 in memory. Each part of the exercise should use the results of previous parts where appropriate. a. Declare an array of type double called numbers with 10 elements, and initialize the elements to the values 0.0, 1.1, 2.2, ..., 9.9. Assume that the symbolic constant SIZE has been defined as 10. b. Declare a pointer nPtr that points to a variable of type double. c. Use a for statement to print the elements of array numbers using array subscript notation. Print each number with one position of precision to the right of the decimal point. d. Write two separate statements that each assign the starting address of array numbers to the pointer variable nPtr. e. Use a for statement to print the elements of array numbers using pointer/offset notation with pointer nPtr. f. Use a for statement to print the elements of array numbers using pointer/offset notation with the array name as the pointer. g. Use a for statement to print the elements of array numbers using pointer/subscript notation with pointer nPtr. h. Refer to the fourth element of array numbers using array subscript notation, pointer/offset notation with the array name as the pointer, pointer subscript notation with nPtr and pointer/offset notation with nPtr. i. Assuming that nPtr points to the beginning of array numbers, what address is referenced by nPtr + 8? What value is stored at that location? j. Assuming that nPtr points to numbers[ 5 ], what address is referenced by nPtr after nPtr -= 4 is executed? What is the value stored at that location?

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.