Write a program 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 an amount.

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,
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’s 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


```
#include
#include
using namespace std;

int main()
{
double amount;
double base = 100000.0;
int i;

cout << "Enter check amount: ";
cin >> amount;
cout << "The protected amount is $";

// calculate how many leading asterisks to insert
for ( i = 0; amount < base; i++ )
base /= 10;

// insert the asterisk(s)
for ( int j = 1; j <= i; j++ )
cout << '*';

cout << fixed << setw( 9 - i ) << setfill( '*' )
<< setprecision( 2 ) << amount << endl;
return 0; // indicates successful termination
} // end main
```
Enter check amount: 22.88
The protected amount is $****22.88

Computer Science & Information Technology

You might also like to view...

The advantage that active incidents have over potential incidents is the time that is normally available to craft a proper response.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Typically, the default font size in Word is ____.

A. 8 B. 12 C. 14 D. 16

Computer Science & Information Technology

The navigation buttons in Access allow you to step through a table record by record, or to quickly go to the first or last record in the table

Indicate whether the statement is true or false

Computer Science & Information Technology

________ time is the time it takes the computer to request and retrieve data

Fill in the blank(s) with correct word

Computer Science & Information Technology