Below I have a payroll application that is fully functional but it doesn't work the way that I would like it to. I have stared at it for a couple hours and I've worn Google out looking for some tips and in the process I landed here. I believe my problem stems from the sentinel value that I'm trying to use to end the program. I think I have it in the right spot for the main function but I'm not sure. Also I am using a void function to display the calculated data per employee and that should be kosher but I need a separate function to calculate and display the total gross pay once the sentinel has ended the main function. I'm not sure what or where that totalGrossPay function should be. Should I assign each gross that is calculated by the main function to a variable and then sum those variables when the sentinel is called? Or should I create some type of running total function that increases as each gross is calculated? Thanks in advance for any and all help you can provide.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include<iostream>
#include<iomanip>
using namespace std;
The issue is not the [code]do....while()[/condition], it's an issue of floats being imprecise, you would need to make a function that compares the float to within reason of -1 (Such as within +/- 0.0001). You could allow the user to enter any negative number to exit, then just test to see if the float is negative.
thanks for your input Intrexa; could you go into a little bit more detail as to why my floats are imprecise and what i can do to fix them. I did not understand this statement: "compares the float to within reason of -1 (Such as within +/- 0.0001)" . Also about the question of calculating and displaying the gross total once the user has exited the main function; How exactly would i do this? Thanks in advance.