4.1k views
1 vote
Write the definition of the function printCheck that prints the hours worked, rate per hour, and the salary.

1 Answer

1 vote

Answer:

Following are the method definition to this question:

void printCheck(int work_hour, float rate_per_hour, float salary)//defining a method printCheck that takes three paramaters

{

cout<<"Hour: "<<work_hour<<endl;//print hour value

cout<<"Rate Per Hour: "<<rate_per_hour<<endl;//print rate/hour value

cout<<"Salary: "<<salary;//print salary value

}

Step-by-step explanation:

The full code to this question can be defined as follows:

#include <iostream>//defining header file

using namespace std;

void printCheck(int work_hour, float rate_per_hour, float salary)//defining a method printCheck that takes three paramaters

{

cout<<"Hour: "<<work_hour<<endl;//print hour value

cout<<"Rate Per Hour: "<<rate_per_hour<<endl;//print rate/hour value

cout<<"Salary: "<<salary;//print salary value

}

int main()//defining main method

{

int work_hour;//defining integer variable

float rate_per_hour,salary;//defining float variable

cout<<"Enter hour and rate/hour value: "<<endl;//print message

cin>>work_hour;//input hour value

cin>>rate_per_hour;//input rate_per_hour value

salary= work_hour*rate_per_hour;//calculating over all salary

printCheck(work_hour,rate_per_hour,salary);//calling method

return 0;

}

Output:

Enter hour and rate/hour value:

4

200

Hour: 4

Rate Per Hour: 200

Salary: 800

In the above-given code a method "printCheck" is declared, that accepts three-parameter "work_hour,rate_per_hour, and salary" in which work_hour is an integer type and other two variables are float type, inside the method print method are used that print the given value.

In the main method an above three variable is used, and in "work_hour and rate_per_hour" variable use for input value from the user end and the salary variable is used to calculate its value, and pass all the value into the method and call it.

User Laela
by
4.7k points