Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Program. Q2: (Weekly Pay Calculator) (25 points) Develop a program that calculates weekly pay for group of hourly workers. Design appropriate prompts and outputs

image text in transcribed

image text in transcribed

C Program.

Q2: (Weekly Pay Calculator) (25 points) Develop a program that calculates weekly pay for group of hourly workers. Design appropriate prompts and outputs of your own design. The program should prompt for the number of hours worked in the week and the hourly rate. Generate the gross weekly pay and print it. Hours over 40 should be paid at time and a half hourly rate. Use a sentinel value to terminate data entry Note: For this program, it is acceptable to use float or double data types for monetary units. However, you should never use float and double data types for monetary unit. Bonus (5 points). Write a small program that illustrates the dangers of using floats (or doubles) for monetary units. Q3: (Bar Charts) (25 Points) Write a program that reads in a series of integers in the range of 1 to 40, with the first number indicating how many integers follow it. Print out a bar chart of the numbers entered. For example, if the following is entered at a prompt Enter integers between 1 and 40 (first number indicates how many there are): 3 10 13 9 You should output the following Q4: (Approximating ) (25 points) The value of can be approximated with the infinite series as follows 1 3 5 7 9 11 Write a program that determines how many terms in takes using the above infinite series to approximate to 3.14159. You can state the answer to this question in the word document you submit, if you obtain the answer through trial and error. Bonus (5 points): Your program should stop itself when the precision is met and output the following It took n terms to approximate pi to 3.14159 Hint: Think about a numerator and a denominator. You learned in a previous homework how to generate odd number sequences. Pay close attention to the sign of each term. Casting: You can eliminate all numbers beyond the 5th decimal position using casting, such as int a = (int)(314159265 * 100000). Here a float is being multiplied by an integer, with the result being a float. The decimal point has been moved 5 places to the right. Use (int) to "cast" that into an integer, truncating all the decimals of the new number, resulting in the new number 314159

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

Students also viewed these Databases questions

Question

1 . 1 0 Convert to hexadecimal and then to binary.

Answered: 1 week ago

Question

c. What groups were least represented? Why do you think this is so?

Answered: 1 week ago

Question

7. Describe phases of multicultural identity development.

Answered: 1 week ago