You hand in this assignment by showing it to the lecturer when it is completed.
Please refer to this page for information on how to work on your assignment.
The task is to write a function which outputs the written names of numbers. So for 0 it should write "zero" and for 15 it should write "fifteen". Furthermore, 101 is "one hundred and one" and 832 is "eight hundred and thirty two". The idea is to fill out the functions to be called such that the correct number is written. Note that there should be an "and" between the hundreds and the later digits if the number is larger than 100 and not a multiple of 100.
The concrete functions to be edited is the multipleten()
function
which currently always returns " twenty"
. But it should be
sensitive to the input and return " twenty"
when d
is 2, " thirty"
when d
is 3, … , " ninety"
when d
is 9. Furthermore, some lines of code in the
numberwrite()
function have to be inserted prior to the
COMPLETE HERE
comment inside the program text of this function.
The goal is to update the name
variable accordingly; this can be
done in approximately five lines. You can put together the codes with commands
like:
if((a > 0) && (b > 1) && (c > 0))
{
name = uptotwenty(a) + " hundred and" + multipleten(b) + name;
}
and must make sure that each appropriate case is covered. In this example, the
last digit c
would already be contained in the name
variable by previous commands and therefore text is added to this variable from
the left.