Sunteți pe pagina 1din 2

ECE 3331 Computer Problem 1 Fall 2013 (due 5pm 9/18)

New Zealand currency consists of $100, $50, $20, $10, and $5 notes and $2, $1, 50c, 20c, 10c and 5c coins. Write a program that will determine, for any given amount, in how many ways that amount may be made up. Changing the order of listing does not increase the count. Thus 20c may be made up in 4 ways: 1 X 20c, 2 X 10c, 10c+2 X 5c, and 4X 5c. Input Input will consist of a series of real numbers no greater than $10.00 each on a separate line from a file cp1.txt. The total number of numbers will not be provided. All amounts will not necessarily be valid. You must read in the numbers one by one until EOF is reached. Output Output will consist of a line for each of the amounts in the input, each line consisting of the amount of money (with two decimal places), followed by the number of ways in which that amount may be made up. For amounts that are not valid, an error message must be shown. Sample output is provided in cp1.out. Sample input 0.20 2.00 0.09 0.10 Sample output 0.20 2.00 0.09 0.10 4 293 error 2

Ideally, the output should be right justified, but since you have not learnt it, we will not ask you. You may, on your own, learn and do so. You may use cp1.txt and cp1.out in developing and testing your program. However, when we execute your program it will be with a different file with this name, probably containing a different number of amounts. You may develop your program in whatever standard "C" environment you prefer, but because we will be compiling and executing it on tuxedo.egr.uh.edu using the gcc compiler with

specific options (refer to the linux gcc handout), you are strongly encouraged to test your program in this environment before turning it in through Engineering blackboard. Some of the more common errors when you move from a C++ system to standard C are: (1) using C++ style comments (//this is not standard C89) (2) placing variable declarations AFTER executable statements (works in C++ but not standard C89) (3) using .C or .cpp as the file extension for the source file rather than .c Remember that your grade will depend not only on getting the right answers but also on program documentation (comments). Be sure you include the specified initial comments, describe each variable, and in the body describe each logical block. Your entire source program must be in a single file, of type .c, which you must begin with your cougarnet username followed by the letters cp1 (no spaces, all lowercase). Turn it in to Engineering Blackboard e.g. my cougarnet name is brsheth and so the file I will turn in is:
brshethcp1.c

S-ar putea să vă placă și