I'm learning C for recreation, and I'm reading this book called C Primer Plus (third edition). Problem 7 from Chapter 7 has you prompt for input of the number of hours worked per week. Then the basic pay rate is $10 per hour, overtime is time & 1/2 (over 40 hours), and the tax rate is .15 for the first $300, .20 for the next $150, and .25 for anything above. it's supposed to output the gross pay, taxes, and net pay. i can't figure out for the life of me how to do this...I'm using a bunch of complicated #define statements.
there's got to be an easier way to do this... thanks for any help!Code:#define PAYRATE 10.00 #define OVERTIME (1.5 * PAYRATE) #define TAX1 0.15 #define TAX2 0.20 #define TAX3 0.25 #define BREAK1 30.0 #define OT_BREAK 40.0 #define BREAK2 45.0 #define GROSS_BASE1 (PAYRATE * BREAK1) /* 300 */ #define GROSS_BASE2 (GROSS_BASE1 + ( (OT_BREAK - BREAK1) * PAYRATE) ) /* 400 */ #define GROSS_BASE3 (GROSS_BASE2 + ( (BREAK2 - OT_BREAK) * OVERTIME) ) /* 475 */ #define NET_BASE1 (GROSS_BASE1 - (GROSS_BASE1 * TAX1) ) /* 255 */ #define NET_BASE2 (NET_BASE1 - ( (GROSS_BASE2 - GROSS_BASE1) * TAX2) + (GROSS_BASE2 - GROSS_BASE1) ) /* 335 */ #define NET_BASE3 (NET_BASE2 - ( (GROSS_BASE3 - GROSS_BASE2) * TAX2) + (GROSS_BASE3 - GROSS_BASE2) )