plz friends help me to solve this proplem by c++ language:

Question (Check Protection and word interpretation)

Problem Concept - Computers are frequently used in check-writing systems, such as pay-roll and accounts payable applications. Many strange stories circulate regarding weekly paychecks being printed (by mistake) for amounts in excess of RM 1 million. Weird amounts are printed by computerized check writing systems because of human error and/or machine failure. Systems designers, make every effort to build controls into their systems to prevent erroneous checks from being issued.

Another serious problem is the international 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 as check protection.

Problem statement: Write a program that inputs a numeric 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 the amount. Extend the program segment to write the word equivalent of the amount in the following line.

Sample Data: Checks designed for imprinting by computer contain a fixed number of spaces in which the computer may print an amount. Suppose a paycheck contains nine blank spaces in which the computer is supposed to print the amount of a weekly paycheck. If the amount is large, then all the nine of those spaces will be filled. For example,

11 ,230 .60 ß check amount
123456789 ß position numbers.

On the other hand, if the amount is less than $ 1000, then several of the spaces wouald be ordinarily left blank. For example:

99 .87 ß check amount
123456789 ß position numbers.

contains 3 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 ß check amount
123456789 ß position numbers.

The program should also print the output of the value of dollars in words in the next line. For example:

112.43 is printed as

RM ***112 .43

Program Output: The program should read a numeric dollar value, and determine the number of spaces before printing its output with proper check-protection. It should also print the value of the dollar in words in the next line aligning it to the right.

Recommended Answers

All 4 Replies

Member Avatar for iamthwee

The first part is simple.

You can use a for loop to print the number of spaces:

for (i = 0; i < V; i++)
   System.out.println(" ");

Where V is a variable. You could make use of string.length() to ascertain the length of the string.

The second part converting numbers to words is a bit harder. But if you google you can find some examples that have already done most of it for you.

thank u friend but how can I find example from google

thank u friend but how can I find example from google

Isn't the point of the assignment for you to learn how to program?
As opposed to learning how to Google for your exact problem?
Which do you want to do -- learn to Google or learn to program?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.