Docstoc

MS-WinWord 7.0 - UCLA

Document Sample
MS-WinWord 7.0 - UCLA Powered By Docstoc
					                               University of California, Los Angeles
                                Electrical Engineering Department
                                EE5C (Winter 98) Assignment #5
                                      Instructor: Cedric Lam

Due: Wednesday, Feb. 11, 1998

The Assignment

          Your company’s sales department is developing a new cash register which will speak out the
amount of the dollar input in words. The development team needs to convert the amount in digits to words
first before they are sent to a voice synthesizer for voice output.

         Write a program which will take the input in digits and print out the dollar and cent values in
words. Your program should validate the user input and reject the incorrect ones. The input can be any
positive real number up to 2100000000 possibly preceded by a $ sign. The leading and trailing spaces and
the space characters between the $ symbol and the number in the input are ignored. There should be no
separation between digits in the input. Digits after the second decimal places are simply ignored. Any
characters other than the period, digits, the dollar symbol and space and tab characters are illegal. The $
symbol and integer part may be omitted in the input. Also, make a difference between singular and plural
forms for “dollars” and “cents” in your output upon the input numerical value.

         For example, the user inputs $ 34.65. Your programs gives: thirty-four dollars and sixty-five cents
as the output.

         The program should also repeatedly prompt the user for new input until the user decides to finish
it.

Sample Input / Output
Input the value of the money you have: 12.34
You entered twelve dollars and thirty-four cents.

Do you want to give another input (y/n)? y
Input the value of the money you have: $ 123.45
You entered one hundred and twenty-three dollars and forty-five cents.

Do you want to give another input (y/n)? y
Input the value of the money you have: 1234.01
You entered one thousand two hundred and thirty-four dollars and one cent.

Do you want to give another input (y/n)? y
Input the value of the money you have: 12345
You entered twelve thousand three hundred and forty-five dollars and zero cent.

Do you want to give another input (y/n)? y
Input the value of the money you have: 1234567891
You entered one billion two hundred and thirty-four million five hundred and
six
ty-seven thousand eight hundred and ninety-one dollars and zero cent.

Do you want to give another input (y/n)? y
Input the value of the money you have: 22.
You entered twenty-two dollars and zero cent.

Do you want to give another input (y/n)? y
Input the value of the money you have: 1
You entered one dollar and zero cent.

Do you want to give another input (y/n)? y
Input the value of the money you have: .223
You entered zero dollar and twenty-two cents.

Do you want to give another input (y/n)? y
Input the value of the money you have: $.23
You entered zero dollar and twenty-three cents.

Do you want to give another input (y/n)? y
Input the value of the money you have: $0.11
You entered zero dollar and eleven cents.

Do you want to give another input (y/n)? y
Input the value of the money you have: $234$
Sorry, incorrect input format.

Do you want to give another input (y/n)? y
Input the value of the money you have: abc
Sorry, incorrect input format.

Do you want to give another input (y/n)? y
Input the value of the money you have: .2.3
Sorry, incorrect input format.

Do you want to give another input (y/n)? n
Thank you.


Miscellaneous Information
1.   You may find the function cin.get() (#include <iostream.h>) and the functions in the file
     <ctype.h> useful. The istream extraction operator cin >> cannot handle the white space
     characters such as the space, tab and return keys. Look up a reference manual.
2.   Check and deal with all forms of unreasonable/bad input as shown in the sample output.
3.   You should find the functions that were developed in Assignment #4 useful.
4.   Use good "style" in writing this program. (see style rules on line /u/ee/class/ee5c/cbin/style.rules) In
     particular, make sure that you use functions and loop the main program.

Grading Breakdown
10%    Compilation (Did the program compile w/out any warnings/errors?)
50%    Execution (Did the program run correctly and pass the test cases?)
40%    Style (see style rules)

Reminders:
1.   The test cases are available on the class web page http://www.seas.ucla.edu/ee5c.
2.   Print out the source code for your program as well as execution outputs. Store the source code on a PC
     formatted floppy disk. Put both the source code and the floppy disk into a manila envelope. Write
     your name and EE5C login id on the front and turn it in. Refer to the EE5C homepage
     http://www.seas.ucla.edu/ee5c for the details of printing and copying files.
3.   E-mail your program to the ee5cta@seas.ucla.edu account before the deadline. Do not make any
     change to your program after the deadline.
4.   Start early!! Avoid deadline bottlenecks!! I will not accept excuses such as “I can’t meet the deadline
     because I couldn’t find a computer”.

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:0
posted:10/21/2013
language:English
pages:2
yan tingting yan tingting
About