Word Calculator

This is a challenge exercise. It is not compulsory, and may be completed individually or with your lab partner.

Create a program called wordAddition.c. This program should ask for two integers using the message Please enter two integers: then display the sum of the integers as n + n = sum.

Any numbers that are between zero and ten should appear as words. This also applies to negative numbers between negative ten and zero. All other numbers should appear as decimal integers.

Make sure to replace the n with the numbers entered in the same order and the sum with the sum of the two numbers.

Some Examples

$ ./wordAddition
Please enter two integers: 2 5
two + five = seven
$ ./wordAddition
Please enter two integers: 3 0
three + zero = three
$ ./wordAddition
Please enter two integers: -1 5
negative one + five = four
$ ./wordAddition
Please enter two integers: 10 5
ten + five = 15

To run some simple automated tests:

$ 1511 autotest wordAddition

To run Styl-o-matic:

$ 1511 stylomatic wordAddition.c
Looks good!

You’ll get advice if you need to make changes to your code.

Submit your work with the give command, like so:

$ give cs1511 wk02_wordAddition

Or, if you are working from home, upload the relevant file(s) to the wk02_wordAddition activity on Give Online.