CS2311 Computer Programming, (14-15, Sem. A)

CS2311 Computer Programming, (14-15, Sem. A)
Assignment 1 – A Change Maker
Due: November 4, 2014, 23:59pm.
Submit to PASS. No late submission will be accepted. Plagiarism
check will be performed.
In North America, there are four types of coins: quarters (25 cents), dimes (10 cents),
nickels (5 cents), and pennies (1 cent).
In this assignment, you are required to implement a simple change maker. It
repeatedly asks the user to enter the amount of cents between 1 and 99, inclusively, as
integers, and outputs the least amount of different types of coins needed to create
change. The program stops when the input is an invalid number, and prints “Goodbye.”
at the end.
For example, the following is a sample run of the change maker. Characters in bold
are entered by the user.
Please enter an amount in cents less than 100: 1
For 1 cent(s): 1 cent.
Please enter an amount in cents less than 100: 2
For 2 cent(s): 2 cents.
Please enter an amount in cents less than 100: 5
For 5 cent(s): 1 nickel.
Please enter an amount in cents less than 100: 6
For 6 cent(s): 1 nickel and 1 cent.
Please enter an amount in cents less than 100: 41
For 41 cent(s): 1 quarter, 1 dime, 1 nickel, and 1 cent.
Please enter an amount in cents less than 100: 66
For 66 cent(s): 2 quarters, 1 dime, 1 nickel, and 1 cent.
Please enter an amount in cents less than 100: 99
For 99 cent(s): 3 quarters, 2 dimes, and 4 cents.
Please enter an amount in cents less than 100: 0
Goodbye.
As you may have observed, the format of the output needs to strictly follow the
English conventions. Specifically,
(1). The program can tell the difference between singular and plural forms. It outputs
“2 quarters”, not “2 quarter”. It is “1 dime”, not “1 dimes”.
(2). If there are 2 types of coins, no comma is needed to connect them, as in the case
of 6 cents. If there are more than 2 types of coins, a comma is needed for each type
except the last, and there should be an “and” before the last type of coin. See the
example for 41 cents.
(3). The proper use of whitespace should also be followed between words, numbers,
and after each comma.
(4). The output is a complete sentence, and ends with a period “.”.
(5). For pennies, output “cent” or “cents” rather than “penny” or “pennies”.
All of these requirements need to be satisfied by your program.
Note that not all types of coins may be needed. See the example of 99 cents, where we
do not need to use nickels. Depending on the user input, it is possible to use 1, 2, 3,
and 4 types of coins.
Note the program outputs the least amount of coins needed. See the example of 5
cents, where only 1 nickel is needed, rather than 5 cents.
You will need to use conditional and loop statements in this assignment. You cannot
use arrays. You will get zero mark if you use arrays in this assignment.
Finally, note that your program output should exactly follow the example above,
including all characters, letter cases, punctuations, etc.
What and How to Submit:
You are required to submit a complete C++ program in one file to PASS.
You may test your program on PASS. You may submit as many times as you want
before the deadline. We will use the latest version of your file for grading.
Only a small set of test cases are available for testing. We will use a more
comprehensive set of test cases for grading. Thus passing all cases in test does not
mean your program is 100% correct. So, try your best to thoroughly test your program.
Grading:
There are two parts: correctness (9 marks), and style (1 mark). A total of 10 marks are
counted towards your final grade for this course.
Correctness: We will simply use PASS to grade for correctness, and see how many
test cases are correct with your program. Thus, if your program cannot even compile
on PASS, you will receive zero mark for correctness.
Style: We will check your source code for indentation, variable naming, comments,
etc. as evidence of good programming style.