Thread: looking 4 help

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    7

    looking 4 help

    Im trying to caculat gross pay.

    my program needs to determine grossPay;
    if (hours<=40) then the person gets paid stright pay
    if(hours>40) then person gets time-and-half
    I should be able to display gross pay.

    using while,if/else structure.
    My output keeps coming 0.00 no matter what i enter.

    Im very frustrated will someone please help. by 2-12-03 11:00pm

  2. #2
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    do your own homework, wrong forum, etc.

  3. #3
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    Post all of your code and maybe some people will help.

    (and in the future, please keep code related posts in the programming boards)

  4. #4
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    heres some help, i'm bored


    /* this was posted while it was still in the c++ forum, so its in C++, its only to help you, its not a solution to your problem.
    */

    Code:
    /*	Steven Billington
    	December 20, 2002
    	NatPine.cpp
    
    	Program finds netpay for employees.
    */
    
    #include "stdafx.h"
    #include <iostream.h>
    #include <iomanip.h>
    
    /*	Prototype functions*/
    double find_gross(double &worked, double &rate);
    double find_net(double &grosspay);
    
    /*	Const for deductions*/
    const double FED_TAX = 0.18;
    const double S_TAX = 0.045;
    const double HOSP = 26.65;
    const double UNION = 7.85;
    
    int main(int argc, char* argv[])
    {
    	/*	Input/function calls*/
    	double hours,
    		   hr_rate,
    		   gross,
    		   net_pay;
    
    	cout<<setiosflags(ios::fixed | ios::showpoint | ios::right)
    		<<setprecision(2);
    
    	/*	Prompt user*/
    	cout<<"Enter hours: ";
    	cin>>hours;
    	cout<<"Enter rate: ";
    	cin>>hr_rate;
    
    	/*	Call function*/
    	gross = find_gross(hours,hr_rate);
    
    	cout<<"\nGross hours worked: "<<"\t"
    		<<gross<<endl;
    
    	/*	Call function, output return*/
    	cout<<"\nNet pay is: "<<"\t\t"
    		<<find_net(gross)<<endl;
    
    	return 0;
    }
    
    /*	Function definition*/
    /*	Function finds gross pay based on user
    	given values*/
    double find_gross(double &worked, double &rate)
    {
    	double gross_pay;
    
    	gross_pay = worked * rate;
    
    	return gross_pay;
    }
    
    /*	Function Declaration*/
    /*	Function finds net pay based on return
    	of find_gross function by making
    	deductions*/
    double find_net(double &grosspay)
    {
    	double net_is,
    		   percent_loss;
    
    	percent_loss = grosspay * FED_TAX;
    	grosspay -= percent_loss;
    	percent_loss = grosspay * S_TAX;
    	grosspay -= percent_loss;
    	grosspay -= HOSP;
    	grosspay -= UNION;
    
    	net_is = grosspay;
    
    	return net_is;
    }
    Last edited by RoD; 02-12-2003 at 04:08 PM.

Popular pages Recent additions subscribe to a feed