Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

how to write a program that displays a weekly payroll report?

+9 votes
asked Oct 30, 2019 by Destiny
A loop in the program should ask the user for the employee number,gross pay, state tax, federal tax, and FICA withholdings. The loop will terminate when 0 is entered for the employee number. After the data is entered, the program should display totals for gross pay, state tax, federal tax, FICA withholdngs, and net pay.

1 Answer

+2 votes
answered Jun 28, 2024 by suhail (410 points)
#include <stdio.h>

int main() {
    int empNumber;
    float grossPay, stateTax, federalTax, FICA;
    float totalGrossPay = 0, totalStateTax = 0, totalFederalTax = 0, totalFICA = 0, totalNetPay = 0;
    float netPay;

    while (1) {
        printf("Enter employee number (enter 0 to terminate): ");
        scanf("%d", &empNumber);
        
        if (empNumber == 0) {
            break;
        }

        printf("Enter gross pay: ");
        scanf("%f", &grossPay);
        printf("Enter state tax: ");
        scanf("%f", &stateTax);
        printf("Enter federal tax: ");
        scanf("%f", &federalTax);
        printf("Enter FICA withholdings: ");
        scanf("%f", &FICA);

        netPay = grossPay - (stateTax + federalTax + FICA);

        totalGrossPay += grossPay;
        totalStateTax += stateTax;
        totalFederalTax += federalTax;
        totalFICA += FICA;
        totalNetPay += netPay;
    }

    printf("\nTotals:\n");
    printf("Total Gross Pay: %.2f\n", totalGrossPay);
    printf("Total State Tax: %.2f\n", totalStateTax);
    printf("Total Federal Tax: %.2f\n", totalFederalTax);
    printf("Total FICA Withholdings: %.2f\n", totalFICA);
    printf("Total Net Pay

    easyyyyyy
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...