/*Author:Piyush Lahoti
Date:20 May 2025 */
#include <stdio.h>
// Define constants for pay rate and tax brackets
#define PAYRATE 12.00
// Base hourly pay rate
#define TAXRATE_300 0.15
// Tax rate for first $300
#define TAXRATE_150 0.20
// Tax rate for next $150 (i.e., from $301 to $450)
#define TAXRATE_REST 0.25
// Tax rate for amount above $450
#define OVERTIME 40
// Standard working hours before overtime
int main() {
int hours = 0;
// Variable to store hours worked
double grossPay = 0.0;
// Total pay before taxes
double taxes = 0.0;
// Total taxes calculated
double netPay = 0.0;
// Pay after taxes
// Ask user for the number of hours worked
printf("Enter the number of hours you worked: ");
scanf("%d", &hours);
// Calculate gross pay
if (hours <= OVERTIME) {
// No overtime; pay is simply hours * base rate
grossPay = hours * PAYRATE;
} else {
// Calculate standard pay for first 40 hours
grossPay = OVERTIME * PAYRATE;
// Calculate overtime pay for hours beyond 40, paid at 1.5x rate
double OverTimePay = (hours - OVERTIME) * PAYRATE * 1.5;
grossPay += OverTimePay; // Add overtime pay to gross pay
}
// Calculate taxes based on gross pay brackets
if (grossPay <= 300) {
taxes = grossPay * TAXRATE_300;
// 15% tax for first $300
} else if (grossPay <= 450) {
taxes = 300 * TAXRATE_300;
// First $300 taxed at 15%
taxes += (grossPay - 300) * TAXRATE_150;
// Remainder taxed at 20%
} else {
taxes = 300 * TAXRATE_300;
// First $300 taxed at 15%
taxes += 150 * TAXRATE_150;
// Next $150 taxed at 20%
taxes += (grossPay - 450) * TAXRATE_REST;
// Remainder taxed at 25%
}
// Calculate net pay after taxes
netPay = grossPay - taxes;
// Display the results
printf("Your gross pay this week: %.2f\n", grossPay);
printf("Your taxes this week: %.2f\n", taxes);
printf("Your net pay this week: %.2f\n", netPay);
return 0;
}