Hi I am new to C Programming and I am looking for some help

Hi,

I am new to C Programming and I am looking for some help.

My instructor has asked that we write a C program that will calculate the pay for employees.

I need help with following:

For each employee the program should prompt the user to enter the

clock number, wage rate, and number of hours. The

clock number

is a unique identifier for an employee, the

wage rate is the hourly

rate the employee is paid, and

hours is how many hours an employee

worked within a given week.

The program determines the gross pay and outputs the following

format:

-----------------------------------

Clock# Wage Hours Gross

-----------------------------------

098401 10.60 51.0 540.60

Column alignment, leading zeros in Clock#, and zero suppression in

float fields are important. Remember that you cannot type in 098401

(its Octal, and invalid as well) ... type in as 98401 and use print

formatting to print as 098401. Assume that clock numbers are at a

most 6 digits long, and pad with leading zeros if less than 6 digits.

Solution

#include <stdio.h>


void main()

{

int datacount = 0; /* Number of test data sets */

int clockNo = 0;

float wage = 0.0;

float hours = 0.0;

float gross = 0.0; /* Variables to hold gross salaries */

int i = 0; /* loop counter */

printf(\"Employee pay calculator\ \ \"); /* Program Info */

printf(\"How many employees data you wish to enter? \"); /* Prompt text */

scanf(\"%d\",&datacount); /* Get test data count from the user */


do

{

printf(\"Enter Employee\'s Clock #: \");

scanf(\"%d\", &clockNo);

printf(\"Enter hourly wage: \");

scanf(\"%f\", &wage);

printf(\"Enter no. of hours worked: \");

scanf(\"%f\", &hours);

gross = wage * hours;

i++;


printf(\"------------------------------------------------\ \");

printf(\"%6s\",\"Clock#\");

printf(\"%10s\",\"Wage\");

printf(\"%10s\",\"Hours\");

printf(\"%10s\ \",\"Gross\");

printf(\"------------------------------------------------\ \");


printf(\"%06d\",clockNo);

printf(\"%10.2f\",wage);

printf(\"%10.1f\",hours);

printf(\"%10.2f\ \",gross);

}

while(i < datacount);

}


Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site