
please wait
|
|
PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code. It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/ http://www.cplusplus.com/articles/z13hAqkS/ Hint: You can edit your post, highlight your code and press the <> formatting button. You can use the preview button at the bottom to see how it looks. I found the second link to be the most help. |
A golden rule: Always initialise your variables. |
grosspay = 16.78 * hours_worked + (1.5) * (16.78) * (hours - hours_worked);
. The () around "1.5" and "16.78" have no real use because they are around a single magic number, i.e., there is no calculation for the () that say do this first.
|
|
grosspay = (PAYRATE * hours_worked) + ((OVERTIMERATE * PAYRATE) * (MAXREGHOURS - hours_worked));
. The use of the constant variables makes it much easier to make changes because they are in one place and you do not have to hunt through the program to find where changes are to be made. This may seem like it is not needed in a program as small as yours, but consider a function with one or two hundred lines of code where a search and replace might change something you do not want to change.if (dependent >= 3.)
. I do not know if "3." is a typo or intended, but what it is doing is comparing an "int" "dependent" to a "double" "3.0". In this case it did not flag any warning or error, but could be a potential problem. Also "dependent" has no usable value other than being initialized to zero when it was defined. So for now the if statement would never be true because "dependent" never receives a value. You should add a prompt and input a value before you reach this if statement.std::cout << std::fixed << std::showpoint << std::setprecision(2);
before your "cout" statements in the "Show all of the outputs" section. The "showpoint" will print ".00" if it comes up and "setprecision(2)" will only print two decimal places.
|
|
grosspay = (PAYRATE * hours_worked) + ((OVERTIMERATE * PAYRATE) * (hours_worked - MAXREGHOURS));
. I had to switch that last part otherwise you could end up with a negative number.