# Write a C program that will calculate the pay for employees

I am looking for help with my class assignment for C Programming. I need to write a program that will calculate weekly pay for employees.

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.

Use the following data as test input:

Clock# Wage Hours

98401 10.60 51.0

526488 9.75 42.5

765349 10.50 37.0

34645 12.25 45.0

127615 8.35 0.0

The program should query the user for how many sets of test data (i.e., employees to process), and loop that many times. In our example above, you would enter the number 5, as there would be 5 employees to process.

Don't expect a nice output that shows all the employee data in a one table. Its OK to have your output show the prompts for data on the first employee, print information about that employee, prompt for information about the next employee, print info on that next employee, and so one until each employee data set is processed.

You will run this program ONE time as stated before, and you will initially prompt the user for the number of data sets to process (such as 5) that you will incorporate into your loop test.

© BrainMass Inc. brainmass.com October 17, 2018, 8:09 am ad1c9bdddfhttps://brainmass.com/computer-science/c/write-program-calculate-pay-employees-571050

#### Solution Preview

I suspect the help you need with this program is about how to format output in the C language. I will get to that in a moment.

The first thing the program will need to do is prompt the user to enter how many employees to process. After reading that input from the user, it will have to perform all the operations for each employee. That implies a loop of some kind. Since the assignment is to loop a given number of times (the number that was entered by the user), a for loop seems reasonable. Something like this:

for (i=0; i<numberOfEmployeesToProcess; i++)

{

/* THIS IS WHERE ALL THE CODE TO PROCESS EACH

** EMPLOYEE WOULD GO

*/

}

For each employee entered, the program has to prompt for, and read, three values, the

clock number, wage rate, and number of hours. A prompt is really just a function call to "printf" followed by a function call to "scanf". The printf function prints the information you want to ask the user, like: "Please enter the social security number 1: ". To get printf to actually print that, you would call it like this:

int i = 1;

printf ("Please enter the social security number %.1d: ", i);

That %d is very important for printf. The way the function works is to substitute things for what appears after the "%". There's a whole bunch of things it does, and that's what you'll need to use to format the output nicely. In this particular case, I'm telling printf to substitute the value in the variable "i" for the %d. Given the way I've just called it, the result should be the same as the prompt in the paragraph above that code. Please note that the ".1" following the percent sign tells the function to only print one digit of the number. If the variable had the value 333 stored in it, the only thing you would see would be this: "Please enter the social security number 3: ". If, however, you called printf like this:

printf ("Please enter the social security number %.4: ", i);

And the value of i at that point was still 333, it would print: "Please enter the social security number 333: ". There are a variety of things the printf function can do with it's formatting. The basics of it are as follows:

The first argument to printf is a character string that may or ...

#### Solution Summary

This (approximately) 1,600 word document will describe the use of the control and substitution characters used with printf and scanf to read and write formatted I/O in the C language.

13 Statistics Questions

Please see attachment. Thank you.

[1.]

A recent article in the Topeka Times reported that 40% of all farms in Kansas will have financial problems this year. A recent survey of 200 farms revealed that 66 of them had financial problems. At the α = 0.01 significance level can we conclude that a smaller proportion of farms actually have problems?

a. State the null and alternative hypothesis statements

b. See the list of formulas at the end of this test to determine the appropriate formula that would be used to calculate the test statistic for this hypothesis test.

c. The test statistic was calculated to be -2.02, determine the p-value.

d. Determine the 99% confidence interval estimate of the proportion of Kansas farms that will have financial problems.

e. Given that the Topeka Times article's estimate of 40% of the farms will have financial problems was a good estimate, how large a sample should they have taken to have been 95% confident in their estimate within an error of 5%?

f. Interpret the results of the hypothesis test, decision and summary.

[2.]

An office manager knows from long experience that 7 percent of the administrative staff will arrive late to work at least once this week.

a. What is the probability that in a sample of 15 staff members none will arrive late at least once this week? ANSWER:

b. What is the probability that in a sample of 15 staff members at least one will arrive late at least once this week? ANSWER:

[3.]

A recent study of the cost per meal in family restaurants in the downtown New York City area were normally distributed with a mean of $18.00 and a standard deviation of $2.50.

a. If a single cost of a meal was selected at random what is the probability that the meal would cost less than $16.00?

b. If a sample of 5 meal costs were selected, what is the probability that the sample mean would be less than $16.00?

[4.]

In your own words (please do not give me a quote from the textbook) write a paragraphexplaining what the p-value is.

[5.]

A large international retail chain is interviewing recent college graduates for potential positions with the company. Each graduate is rated as either below average, average or above average with respect to technical knowledge and each graduate is also rated with respect to his or her potential for advancement; fair, good, or excellent. These traits for 500 recent graduates are summarized in the following table.

Potential For Advancement

Technical Knowledge Fair Good Excellent Total

Bellow average 16 12 22 50

Average 45 60 45 150

Above average 93 72 135 300

Total 154 144 202 500

a. If a single recent graduate was selected at random what is the probability they would have technical knowledge or have excellent potential for advancement?

b. If a single recent graduate was selected at random what is the probability they would have above average technical knowledge and good potential for advancement?

c. If a single recent graduate was selected at random what is the probability they would have below average sales ability given they have good potential for advancement?

[6.]

In your own words (please do not give me a quote from the textbook) write a paragraph defining "Inferential Statistics".

[7.]

A consumer organization wants to know whether there is a significant difference in the price of a particular model of portable cd players at three different types of stores. The price of the cd player was checked in a sample of 5 discount stores, 5 variety stores and 5 department stores. The results are shown below (all prices are in dollars). Test to see if there is a significant difference in the prices between the three types of stores using a significance level of α = 0.05. The test statistic for this test was calculated to be 13.38.

Discount Variety Department

12 15 19

13 17 17

14 14 16

12 18 20

15 17 19

a. State the null and alternative hypothesis statements.

b. Determine the critical value.

c. See the list of formulas at the end of this test to determine the appropriate formula that would be used to calculate the test statistic for this hypothesis test.

d. Interpret the results.

[8.]

At a local pizza restaurant the owner believes that 50% of the customers will pay by cash, 25% will pay with a credit card and another 25% will pay with a personal check. The owner asked the manager to collect a random sample of two hundred customers to see their method of payment and test to see if the owner was correct, the survey results are below. Can it be

concluded that the owner is correct? Use the significance level of α = 0.05.

Cash Credit Card Check

Frequency 112 48 40

a. State the null and alternative hypothesis statements.

b. Determine the critical value.

c. See the list of formulas at the end of this test to determine the appropriate formula that would be used to calculate the test statistic for this hypothesis test.

d. The test statistic was calculated to be 3.52, interpret the results.

[9.]

In your own words, write a paragraph defining what a "Hypothesis Test" is. (Don't give me an example of one, nor tell me how to construct one; tell me what it is, its use, and its interpretations.)

[10.]

A psychologist conducted a recent study to determine whether the fact that whether a student was left or right-handed was independent of their ability to perform will in a statistics class. The following are the results of the study. The test statistic for this test was calculated to be 18.18.

Handedness

Ability Left Right

Bellow average 40 52

Average 106 47

Above average 67 32

What is your conclusion using a significance level of α = 0.05

a. State the null and alternative hypothesis statements.

b. Determine the critical value.

c. See the list of formulas at the end of this test to determine the appropriate formula that would be used to calculate the test statistic for this hypothesis test.

d. Interpret the results.

[11.]

The research department at the home office of New Haven Insurance conducts ongoing research on the causes of automobile accidents, the characteristics of the drivers and so on. A random sample of 400 policies written on single persons revealed 120 had at least one accident in the previous three-year period. Similarly, a sample of 600 policies written on married persons revealed that 150 had been in at least one accident. At the α = 0.05 level of significance, is there a significant difference in the proportions of single and married persons having an accident during the last three-year period? For this test, the test statistic was calculated to be -1.74.

a. State the null and alternative hypothesis statements.

b. See the list of formulas at the end of this test to determine the appropriate formula that would be used to calculate the test statistic for this hypothesis test.

c. Determine the p-value.

d. Interpret the results.

[12.]

The director of the Atlanta office for Delta Airlines would like to compare the weights of checked baggage for families of four people and compare those weights between families who are traveling overseas for vacations against those families of four who are flying within the United States for vacation. She collected the following sample information:

Overseas Domestic

x = 142.50 ñb x = 130.25 lb

s = 12.25 lb s = 15.75 lb

n = 6 n = 7

The degrees of freedom for this comparison were calculated to be 10. At the α = 0.10 level of significance, can she conclude that the mean weights of the checked baggage for the families flying overseas is greater than the weights of the families making domestic flights?

a. State the null and alternative hypothesis statements.

b. Determine the critical value.

c..See the list of formulas at the end of this test to determine the appropriate formula that would be used to calculate the test statistic for this hypothesis test.

d. The test statistic for this test was calculated to be 1.58, interpret the results.

[13.]

At a General Electric refrigerator assembly plant, the director of human resources has noticed an increase in number of hours lost to on-the-job accidents. Four years ago, in an attempt to improve the situation, he began a safety awareness program in which employees heard safety announcements and suggestions during their lunch hour in the cafeteria. To evaluate the program, he selected a random sample of eight participants and found the number of hours each lost in the six months before the safety awareness program began and in the last six months. Below are the results. At the α = 0.05 significance level, can he conclude that the number of hours lost has declined?

Employee Before After

1 6 5

2 6 2

3 7 1

4 7 3

5 4 3

6 3 6

7 5 3

8 6 7

a. State the null and alternative hypothesis statements.

b. Determine the critical value.

d. The test statistic for this test was calculated to be -1.70, interpret the results.

View Full Posting Details