Question

In: Computer Science

Design and write a function to calculate a person’s pay for a variable number of hours...

Design and write a function to calculate a person’s pay for a variable number of hours worked.
● Create a constant called HOURLY_RATE set to 24.95
● To Consider - should this be local to the function or global?
● Ask the user to enter their number of hours worked (do this inside the function). Remember to always use meaningful variable names for variables!
● Then calculate and return their total pay

Add code to main which will call this function and display their pay.

Float

Solutions

Expert Solution

SOURCE CODE:

*Please follow the comments to better understand the code.

**Please look at the Screenshot below and use this code to copy-paste.

***The code in the below screenshot is neatly indented for better understanding.

#include <stdio.h>

//Global Variable
#define HOURLY_RATE 24.95

float calculate_pay(float hours_worked)
{
//Multiply the values and return the result
return hours_worked * HOURLY_RATE;
}

int main()
{
float hours_worked, pay;
//Input the data
   printf("Enter the number of hours worked: ");
   scanf("%f",&hours_worked);
  
   //Call the function
   pay= calculate_pay(hours_worked);
  
   //print the result
   printf("Pay = %f",pay);
   return 0;
}

==============

SCREENSHOT:


Related Solutions

Design and write a function which will calculate and display the stock level of a product...
Design and write a function which will calculate and display the stock level of a product at the end of the day. The function will take as input the initial stock level, the amount we bought and the amount we sold. Add lines to main which get 3 values from the user, as shown below, the pass them to the function. Sample output: Enter stock at start of day: 20 Enter amount of new stock received today: 10 Enter amount...
Design a program using a flowchart or pseudocode that accepts a person’s loyalty card number and...
Design a program using a flowchart or pseudocode that accepts a person’s loyalty card number and amount spent in the store last month. Display the data only if the customer is a high spender – a person who spent more than $1000 in the store. A program that accepts customer info continuously until a sentinel value is entered and displays a list of high spenders.
The variable Hours Studied represents the number of hours a student studied for their final exam...
The variable Hours Studied represents the number of hours a student studied for their final exam and the variable Final Exam Grade represents the final exam score the student received on their final exam (out of 100 points).An introduction, explanation/interpretation of your analysis, and a conclusion. Hours studied- 1, 0, 7, 9, 9, 5, 4, 2, 11, 7, 13, 3, 3, 1, 9, 7, 5, 0, 2, 8 Final Exam grade 70, 54, 81, 92, 90, 78, 75, 68, 98,...
Write a function that takes a person’s first and last names as input and (a) uses...
Write a function that takes a person’s first and last names as input and (a) uses lists to return a list of the common letters in the first and last names (the intersection). (b) uses sets to return a set that is the intersection of the characters in the first and last names. (c) uses sets to return the set that is the symmetric difference between the first and last names. please write in python program
Using Matlab Write a function, called digits_function that is able to calculate the number of digits...
Using Matlab Write a function, called digits_function that is able to calculate the number of digits and the multiplication of the digits. The input of this function is N (entered number) and the outputs are number_digits and sum_digits.
Write a recursive function to calculate and return factorial of a given number 'n'. in C...
Write a recursive function to calculate and return factorial of a given number 'n'. in C progrmaining
how do you determine the number of regular hours and overtime hours for the pay period?
how do you determine the number of regular hours and overtime hours for the pay period?
C++ Suppose  getAcctNum() returns the account number of a given Account variable.  Write a function that returns a...
C++ Suppose  getAcctNum() returns the account number of a given Account variable.  Write a function that returns a boolean value to find if a given account number appears in an array of Account objects.
(Please use mini tab if possible)The variable Hours Studied represents the number of hours a student...
(Please use mini tab if possible)The variable Hours Studied represents the number of hours a student studied for their final exam and the variable Final Exam Grade represents the final exam score the student received on their final exam (out of 100 points).An introduction, explanation/interpretation of your analysis, and a conclusion. Hours studied- 1, 0, 7, 9, 9, 5, 4, 2, 11, 7, 13, 3, 3, 1, 9, 7, 5, 0, 2, 8 Final Exam grade 70, 54, 81, 92,...
- Design and implement a function with no input parameters. The function keeps receiving a number...
- Design and implement a function with no input parameters. The function keeps receiving a number from input (user) and adds the numbers together. The application keeps doing it until the user enter 0. Then the application will stop and print the total sum and average of the numbers the user had entered.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT