Homework 1, Count your Arguments.
Short Description:
Write a program that uses command line arguments.
Goals
When you finish this homework, you should have:
- Demonstrated your ability to parse and use command line arguments.
Formal Description
Write a program that will count from 1 to 10 by 1. The default output should be
1, 2, 3, 4, 5, 6 , 7, 8, 9, 10
There should be only a newline after the last number. Each number except the last should be followed by a comma and a space.
To make your program more functional, you should parse command line arguments and change behavior based on their values.
Argument | Parameter | Action |
-f, --first | yes, an integer | Change place you start counting |
-l, --last | yes, an integer | Change place you end counting |
-s, --skip | optional, an integer, 1 if not specified | Change the amount you add to the counter each iteration |
-h, ? | none | Print a help message including these instructions. |
-j, --joke | none | Tell a number based joke. |
So, if your program is called counter
counter -f 10 --last 4 --skip 2
should produce
10, 8, 6, 4
Please use the last supplied argument. If your code is called counter,
counter -f 4 -f 5 -f 6
should count from 6.
You should count from first to last inclusively.
You you may not display the last number if the skip value is something other than 1.
The skip value should always be greater than 0.
Notes
- You can use any number of sites on the internet to find a number based joke. What do you call numbers that won't stay in one place? Roamin' numerals.
- You can use any library you find helpful to perform this task. You can do it without a library as well if you wish.
- You may write this in c or c++. If you wish for extra credit, I will add 50% to your grade for a well written program in bash or python. No, we have not yet covered either of those, but it is extra credit. Total of 200% of the score.
Required Files
A single c/c++ source code file that solves the problem. If you do multiple versions, submit a zip or tar file containing all of your source code.
Submission
Submit the assignment to the D2L folder Homework 1 by the due date.