Write a C program that runs on ocelot for a salary calculator using only the command line options. You must use getopt to parse the command line.
The calculator will only do bonuses and raises to a base salary as well as a veterans bump.
Usage: salary [-b bnum] [-r rnum] [-v] base
The variable base is the starting salary where the base should be validated to be an integer between 50000 and 100000 inclusive. It would represent a salary. Error message and usage shown if not valid.
For the -b option bnum should be a positive integer between 1 and 10 inclusive. It would represent the multiplier for a bonus on top of the salary. Error message and usage shown if not valid.
For the -r option rnum should be a positive integer between 5 and 10 inclusive. It would represent a percentage raise based on the salary. Error message and usage shown if not valid.
-b adds (bnum times 1000) to the base.
-r multiplies the base by the percentage given and adds it to the base.
-v adds an 8000 bump to the base.
Output should have exactly 2 decimal places no matter what the starting values are as we are talking about money.
If -v is included, it is executed first. If -r is included it would be executed next. The -b would be executed last.
There will be at most one of each option, if there are more than one you can use either of the options in the calculation.
Code should be nicely indented and commented.
Create a simple Makefile to compile your program into an executable called salary.
Test your program with the following command lines and take a screenshot after running the three lines. The command prompt should be viewable.
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly complete the form.
Please provide a valid email address and we will get back to you within 24 hours.
Payment is through PayPal, Buy me a Coffee
or Cryptocurrency.
We are a nonprofit organization however we need funds to keep this organization operating
and to be able to complete our research and development projects.