Taxes and Functions

Well my job was to create a program that would get the gross pay, taxes and net pay based on the following info; $10/hr, Overtime(excess of 40 hrs: $15/hr, 15%tax on first $300, 20% on next $150, and 25% tax on the rest. I did this and it works for lower number like 27 hours, but when I get into higher hours and overtime stuff doesn't work. Any tips?

#include<iostream>
using namespace std;
// List Functions
float Payrate(int hours_worked);
float Tax1(float First300);
float Tax2(float Next150);
float Tax3(float FinalMoney);


int main()
{
int Hours,Gross_pay;
float Total_Tax,Net_Pay;
float T1 = 0;
float T2 = 0;
float T3 = 0;
cout<< "How many hours have you worked this week?\n";
cin>> Hours;
Gross_pay = Payrate(Hours);

if(Gross_pay<=300)
{
T1 = Tax1(Gross_pay);
}
else if(Gross_pay>300 && Gross_pay <=450)
{
T1 = Tax1(Gross_pay);
T2 = Tax2(Gross_pay);
}
else if(Gross_pay>450)
{
T1 = Tax1(Gross_pay);
T2 = Tax2(Gross_pay);
T3 = Tax3(Gross_pay);
}
Total_Tax = T1+T2+T3;
Net_Pay = Gross_pay - Total_Tax;
cout.precision(2);
cout<<fixed;
cout<< "Gross Pay: $" <<Gross_pay<<endl;
cout<< "Taxes: $" <<Total_Tax<<endl;
cout<< "Net Pay: $" <<Net_Pay<<endl;
system("pause");
return 0;

}
float Payrate(int hours_worked)
{
int Gross = 0;
int extra = 0;
int OT = 0;
//
if(hours_worked>40)
{

OT = hours_worked-40;
extra = OT*15;
Gross = extra + 400;
}
else
{
Gross = (hours_worked*10);
}
return(Gross);
}
//
float Tax1(float First300)
{
float Tax;
do
{
cout.precision(2);
cout<<fixed;
Tax = First300*.15;
return(Tax);
}
while(First300<=300);
}

float Tax2(float Next150)
{
float Tax;
do
{
cout.precision(2);
cout<<fixed;
Tax = Next150*.2;
return(Tax);
}
while(Next150<=450 && Next150>300);
}
float Tax3(float FinalMoney)
{
float Tax;
do
{
cout.precision(2);
cout<<fixed;
Tax = FinalMoney*.25;
return(Tax);
}
while(FinalMoney>450);
}
1
2
3
4
5
6
7
8
9
10
11
12
float Tax3(float FinalMoney)
{
    float Tax;
    do
    { 
        cout.precision(2);
        cout<<fixed;
        Tax = FinalMoney*.25;
        return(Tax);
    }
    while(FinalMoney>450);
}

Why do you use completely pointless while loop?
How the Tax counted? Is $500 tax is 300*.15 + 150*.20 + 50*.25?
If so, your tax2 and tax3 functions is wrong. You either need to pass (Gross_pay - 300) (or - 450 ( - 300 - 150) for Tax3) or to deduce 300|450 in those functions.
You are right about how the tax is counted, and I will work on fixing it. Thanks for your help.
Topic archived. No new replies allowed.