I am trying to get the program to display empID - unionCode so the user can input certain data and then I also want the program to display regularPay-netPay with just data that was computed by the original information that the User put in those first 5 data entries
It had some errors in which told me assignment to "int" from "double", can anyone offer any guidance please?
I am very new to C++, but hopefully this answer is accurate enough to be useful:
I suggest using all double types instead of int types,
since that seems to fit with the calculations you are doing.
Anywhere you are assigning a double expression to an int will have the error you described.
For example, on line 53: regularPay = 40 * payRate;
40 is type int
payRate is type double
regularPay is type int
The type of the (40 * payRate) expression will up convert to the largest type, in this case "double" because of payRate.
Then assigning that double result to the int payRate will cause an error due to the loss of precision.
You probably do not want the line below, but it would remove the error: regularPay = (int)(40 * payRate);
That line is casting the double value to an int, but you will lose the decimal precision.
For example, the value of myVar below is "5", not 5.7. int myVar = (int)5.7;
Using all double types instead will avoid loss of decimal precision.
ok, I revised my code, how do I implement those if/else statements correctly? Are they in the ok position or should they be moved elsewhere?
Also
So I compile and run and it goes up to regular pay which does the arithmetic like it should only except how do I get it to display regular pay without having the cin underneath it?
If I understood the question right, you would only need cin if you want to read input from the user.
You could just delete line 29 because regularPay is already assigned a value.
If you want to display all of the final values at the end, after the if/else, you could do: