Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

(Check Protection) Computers are frequently employed in check-writing systems, such as payroll and accounts payable applications. There are many strange stories about weekly paychecks being printed (by mistake) for amounts in excess of $1 million. Incorrect 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 plans to cash a check fraudulently. To prevent a dollar amount from being altered, some 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 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 the spaces will be filled. For example, 1,230.60 (check amount) 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 an application that inputs a dollar amount to be printed on a check, then prints the amount in check-protected format with leading asterisks if necessary. Assume that nine spaces are available for printing the amount.

Short Answer

Expert verified
Format the dollar amount with leading asterisks so its length is nine characters.

Step by step solution

01

Understand the Problem

The task is to take a dollar amount for a check and format it such that it has leading asterisks if the amount has fewer than nine total characters, including the decimal and cents. This serves to protect the check against alterations.
02

Input the Dollar Amount

Take the dollar amount from the user as input. Ensure this is a valid monetary value including at least a decimal and two digits for the cents (e.g., 1234.56).
03

Convert the Amount to String

Convert the input dollar amount to a string. This makes it easier to calculate its length and manipulate it by adding characters if necessary.
04

Calculate Remaining Spaces

Find out how many characters short the dollar amount is from nine characters by using the formula:needed\_characters=9length of the dollar amount string
05

Add Leading Asterisks

If the `needed_characters` is greater than zero, create a string with that many asterisks. Concatenate this string in front of the dollar amount string. If the length of the dollar amount string is already nine or more, no asterisks are needed.
06

Output the Formatted Check Amount

Print the final formatted string, which should now have the dollar amount with leading asterisks such that the total length is nine characters.

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 Vaia!

Key Concepts

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

computerized check-writing systems
Computerized check-writing systems have revolutionized the way checks are processed and printed. These systems are commonly used in various financial applications such as payroll and accounts payable. They enable computers to automatically fill out checks, reducing human error and speeding up the financial documentation process.
However, despite their efficiency, errors can still occur due to machine glitches or incorrect input data. To mitigate these issues, system designers implement various controls to ensure the accuracy and security of printed checks.
These systems deal with various challenges such as ensuring the correct amount is printed, preventing unauthorized alterations, and maintaining the integrity of the financial transactions.
check alteration prevention
When it comes to financial transactions, check alteration is a significant concern. If a check is left with any blank spaces when printed, it can become susceptible to tampering. This is where automated systems step in to enhance security.
Check alteration prevention techniques focus on ensuring that the amounts cannot be easily modified after printing. One such method involves padding the check amount with leading characters, such as asterisks. By doing so, any unused spaces are effectively filled, preventing anyone from adding extra digits to the check amount.
This simple yet effective strategy ensures that checks are safeguarded against fraudulent activities, maintaining reliability in financial dealings.
formatted check printing
Formatted check printing involves producing checks in a manner that adheres to specific formatting rules. Automated systems ensure that every check is consistent and presents no security vulnerabilities.
For example, in a classic formatted check printing challenge, if the whole amount, including the dollar, cents, and formatting characters, doesn't fill the designated space, leading asterisks are used. This fills in any voids, aligning the printed output with predefined standards.
Such meticulous formatting helps in easily identifying inconsistencies or suspicious alterations, thereby enhancing the payment's security and authenticity.
programming assignment
Programming assignments, such as creating applications for check protected formats, are essential exercises for aspiring developers. They not only enhance coding skills but also underline the importance of understanding real-world applications. In creating an application for check protection, developers must consider user inputs, string manipulation, and output formatting.
  • User Inputs: Ensuring the entry is a valid dollar amount.
  • String Manipulation: Calculate the existing length and determine if leading asterisks are needed.
  • Output Formatting: Format and print the check with the correct number of total characters.
Through such projects, programmers learn how to safeguard financial documents against fraud and utilize logical thinking to solve complex real-world problems.

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

Many popular word-processing software packages have built-in spell checkers. In this project, you are asked to develop your own spell-checker utility. We make suggestions to help get you started. You should then consider adding more capabilities. Use a computerized dictionary (if you have access to one) as a source of words. Why do we type so many words with incorrect spellings? In some cases, it is because we simply do not know the correct spelling, so we make a best guess. In some cases, it is because we transpose two letters (e.g., "defualt" instead of "default"). Sometimes we double-type a letter accidentally (e.g., "hanndy" instead of "handy"). Sometimes we type a nearby key instead of the one we intended (e.g., "biryhday" instead of "birthday"), and so on. Design and implement a spell-checker application in Java. Your application should maintain an array wordList of strings. Enable the user to enter these strings. [Note: In Chapter 14, we have introduced file processing. With this capability, you can obtain the words for the spell checker from a computerized dictionary stored in a file.] Your application should ask a user to enter a word. The application should then look up that word in the wordList array. If the word is in the array, your application should print "Word is spelled correctly." If the word is not in the array, your application should print "Word is not spelled correctly." Then your application should try to locate other words in wordList that might be the word the user intended to type. For example, you can try all possible single transpositions of adjacent letters to discover that the word "default" is a direct match to a word in wordList. Of course, this implies that your application will check all other single transpositions, such as "edfault," "dfeault," "deafult," "defalut" and "defautl." When you find a new word that matches one in wordList, print it in a message, such as Did you mean "default"? Implement other tests, such as replacing each double letter with a single letter, and any other tests you can develop to improve the value of your spell checker.

Write an application that will assist the user with metric conversions. Your application should allow the user to specify the names of the units as strings (i.e., centimeters, liters, grams, and so on, for the metric system and inches, quarts, pounds, and so on, for the English system and should respond to simple questions, such as "How many inches are in 2 meters?" "How many liters are in 10 quarts?" Your application should recognize invalid conversions. For example, the question "How many feet are in 5 kilograms?" is not meaningful because "feet" is a unit of length, whereas "kilograms" is a unit of mass.

Write an application that reads a line of text, tokenizes it using space characters as delimiters and outputs only those words ending with the letters "ED".

Write an application that reads a line of text, tokenizes the line using space characters as delimiters and outputs only those words beginning with the letter "b".

Write an application that inputs a line of text and outputs the text twice -once in all uppercase letters and once in all lowercase letters.

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.

Sign-up for free