I've compiled and run it without problems;
Enter the number corresponding to ... : 1
Please enter the number of ... : 40
Output:
Gross Pay - 365.50
Payable Tax - 58.10
Net Pay - 307.40
Which was your test data for which the program crashed?
Chaster
Junior Poster in Training
68 posts since Jun 2007
Reputation Points: 12
Solved Threads: 3
There are lots of defects in this code but it works after minimal corrections.
1. Uncomment choices 2-4: replace bad function name from taxcal to tax_cal.
2. Avoid unnecessary label and goto statement. Use normal C loop in that case, for example:
for (;;) {
/* input payrate_index with prompting */
if (!payrate_index)
break;
if (payrate_index < 0 || payrate_index > 4) {
/* print bad choice message */
continue;
}
/* input worked_hours with prompting */
/* place switch statement here (default for code logics error only) */
}
What for you ask user to input worked_hours for bad payrate_index?
In that case you can calculate more than one payrate w/o annoying program restart...
3. Append \n in format string literals.
4. Replace all float vars to double vars. I think worked_hours var must be double too.
5. Use int main(), not void main()!
6. Avoid a crudely constructed 1st message with cumbersome ********. Print a simple and clear welcome/help message.
Now you don't print a prompt message for bad payrate_index so it seems that the program is frozen...
ArkM
Postaholic
2,001 posts since Jul 2008
Reputation Points: 1,234
Solved Threads: 348