question archive Write a program that will iterate over the input, adding the digits, and returning the result
Subject:SociologyPrice:13.89 Bought3
Write a program that will iterate over the input, adding the digits, and returning the result.
Input:
- MUST accept STDIN as the default
- MUST accept a file when flag [-f] is specified
- MUST handle hex values when flag [-x] is specified
Output:
- MUST output result as Long to STDOUT
- MUST always output result in base 10
Be sure to include:
- README on how to build/test/execute your application
- Automated Unit Tests
Examples:
$ echo "abc123" | ./myProg
6
$ echo "abc123" | ./myProg -x
39
$ echo "qq" | ./myProg
0
$ echo "abc123" > file.tmp
$ ./myProg -f file.tmp
6
Purchased 3 times