I was up until 4AM last night trying to figure this out for my payroll project. I just can't get it... My dilemma is incorporating the deduction of union dues from the net pay. Union dues are based on union code (A, B, or C). I also can't seem to get the program to accept LETTERS instead of NUMBERS as the union code. I have temporarily changed the coding to numbers.
-Don't understand how to make switch work
-Need to use letters instead of numbers for union code
-Currently program closes when entering a union code
EDIT: Removed some problem code. Inserted breaks in the switch statement. Program now functions as intended. Unresolved issues are how to display union code as a letter. Also when trying to output unionCode at the end of the program I get a string of garbage. Why is this?
To make the switch work, add a break; at the end of each case.
To use letters for union codes, declare unionCode as a char.
Your crash may be due to the fact you keep accessing unionCode. You declared unionCode as int unionCode;, which means the only existing element is unionCode.
Line 71 : a "else" doesn't take any condition.
Since you do not use brackets, your compiler will consider that (grossPay > 2000); is the code for your "else" and that federalTax = .25; is outside the if/else if/ else code. As a consequence you will always apply a federal tax of 0.25