Thread: PayRoll Program- Look!

  1. #1
    Registered User ProgrammingDlux's Avatar
    Join Date
    Jan 2002
    Posts
    86

    PayRoll Program- Look!

    Hey, I need Help with this program I'm doing. I need it to assign regular pay for a person that works 40 hours or less and over time hours at a rate of time and a half for any hours over 40. My PROBLEM is when i put any hours over 40, it calculates the total hours as 40 only and outputs gross, taxes, etc. based on 40 hours...What is wrong here?

    #define CB cin.ignore(cin.rdbuf()->in_avail())
    #define Max 3 // Maximum Employees
    #include<iomanip.h>
    #include<stdlib.h>
    #include<math.h>
    main()
    {//_asm finit;
    int Hour, Emp; char Name[20], SocSec[11];
    float PayRate,OTRate=PayRate*1.5, StateRate;
    float FedRate, Gross=0, StTax,FedTax,Net,OvrTime,RegPay;

    for(Emp=1;Emp<=Max;Emp++)
    {cout<<"\nEmployee Number : "<<Emp;
    cout<<"\nEnter Name : ";cin.getline(Name,20);CB;
    cout<<"Enter Social Security Number: ";cin.getline(SocSec,11);CB;
    cout<<"Enter Number of Hours worked: ";cin>>Hour;CB;
    cout<<"Enter Pay Rate (Hourly) : ";cin>>PayRate;CB;
    cout<<"Enter State Tax Rate : ";cin>>StateRate;CB;
    cout<<"Enter Federal Tax Rate : ";cin>>FedRate;CB;

    RegPay=40*PayRate;
    OvrTime=((Hour-40)*OTRate);
    StTax=Gross*StateRate;
    FedTax=Gross*FedRate;
    Net=Gross-(StTax+FedTax);

    if(Hour<=40)
    {Gross=Hour*PayRate;}
    else
    {Gross=((RegPay)+((Hour-40)*OTRate));}


    cout.setf(ios::floatfield,ios::showpoint);
    cout.setf(ios::fixed);
    cout<<setprecision(2);

    cout<<"\nName : "<<Name;
    cout<<"\nSSN : "<<SocSec;
    cout<<"\nPay Rate (Hourly): $"<<PayRate;
    cout<<"\nState Tax Rate : $"<<StateRate;
    cout<<"\nFederal Tax Rate : $"<<FedRate;
    cout<<"\nState Taxes : $"<<StTax;
    cout<<"\nFederal Taxes : $"<<FedTax;
    cout<<"\nGross Pay : $"<<Gross;
    cout<<"\nRegular Pay : $"<<RegPay;
    cout<<"\nOvertime Pay : $"<<OvrTime;
    cout<<"\nNet Pay : $"<<Net<<endl;

    }
    system("PAUSE");
    return 0;
    }

    Thanks for any Help

  2. #2
    Unregistered
    Guest
    when you intialize OTRate to PayRate*1.5 PayRate is undetermined as it hasn't been given a value yet. Don't initialize OTRate. Assign it the value of PayRate*1.5 after you have given PayRate a value in your loop.

  3. #3
    Unregistered
    Guest
    Hey Thanks...I can't believe I overlooked that

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  2. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  3. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  4. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM