Comments | Online Safety | Help
     
  /* This code calculates the overtime hours worked at time and a quarter, and also calculates tax/national insurance payable
 * (very basic calculation) - http://www.incubus.co.uk - Borland Turbo C++ */



#include <stdio.h>
#include <stdlib.h>

#define INCOME_TAX 24.00 /* Income Tax rate percentage figure. */
#define NATIONAL_INS 7.00 /* National Insurance rate percentage figure. */
#define TAX_FREE 68.00 /* Tax free allowance in pounds. */

int main (void)
{   int hours_worked = 0,
        hours_over = 0;
    float hourly_rate = 0.0,
        taxable_pay = 0.0,
        gross_pay = 0.0,
        net_pay = 0.0;

    /* Get input from keyboard. */
    printf("Enter hours worked - ");
    scanf("%d",&hours_worked);
    printf("Enter hours overtime worked - ");
    scanf("%d",&hours_over);
    printf("Enter hourly rate of pay - $");
    scanf("%f",&hourly_rate);

    /*Calculate gross pay, taxable pay and net pay for week worked. */
    gross_pay = ((hours_worked * hourly_rate) + (hourly_rate * 1.25 * hours_over));
    taxable_pay = gross_pay - TAX_FREE;
    net_pay = gross_pay - (((NATIONAL_INS + INCOME_TAX)/ 100) * taxable_pay);

    /* Display wage information for one week worked. */
    printf("Hours worked = %d \n", hours_worked);
    printf("Overtime worked = %d \n", hours_over);
    printf("Basic rate of pay = $%.2f \n", hourly_rate);
    printf("Overtime rate of pay = $%.2f \n", hourly_rate * 1.25);
    printf("Gross pay = $%.2f \n", gross_pay);
    printf("Taxable pay = $%.2f \n", taxable_pay);
    printf("National Insurance contribution = $%.2f \n", (NATIONAL_INS / 100) * taxable_pay);
    printf("Income tax payble = $%.2f \n", (INCOME_TAX / 100) * taxable_pay);
    printf("Nett pay (weekly wage) = $%.2f \n", net_pay);

    return EXIT_SUCCESS;
}