Defines a function that computes net pay. - C++ Function

C++ examples for Function:Function Creation

Description

Defines a function that computes net pay.

Demo Code

#include <iostream>
using namespace std;  
void main(void);
float netpayfun(float hours, float rate, float taxrate);
void main(void)
{
   float net_pay;
   net_pay = netpayfun(40.0, 3.50, .20);
   cout << "The pay for 40 hours at $3.50/hr., and a 20% " << "tax rate is $";
   cout << net_pay << "\n";
   net_pay = netpayfun(50.0, 10.00, .30);
   cout << "The pay for 50 hours at $10.00/hr., and a 30% " << "tax rate is $";
   cout << net_pay << "\n";
   net_pay = netpayfun(10.0, 5.00, .10);
   cout << "The pay for 10 hours at $5.00/hr., and a 10% " << " tax rate is $";
   cout << net_pay << "\n";
   return;// www . jav a2 s  . com
}
float netpayfun(float hours, float rate, float taxrate)
{
   float gross_pay, taxes, net_pay;
   gross_pay = (hours * rate);
   taxes = (taxrate * gross_pay);
   net_pay = (gross_pay - taxes);
   return (net_pay);
}

Result


Related Tutorials