help with my tax function!

here is my program. thanks to everyones help im almost done! my tax fucntion wont work though. any suggestions?
#include <iostream>
#include <fstream>

using namespace std;

double grosspay(double,int);
double taxfun(double);
int main()
{
int amount, data, overtime;
double wage;
ifstream file;
file.open("empdata.txt");
if(!file)
cout <<"lets try again";

file >> amount;
for(int i=1; i<=amount; i++){
file >> data;
file >> wage;
file >> overtime;
cout << data <<" " << wage <<" " << overtime << endl;
cout << grosspay(wage,overtime) <<" "<< taxfun(grosspay(wage,overtime)) << endl;



}
return 0;
}


double grosspay(double hrate, int hrs){
double pay =hrate*hrs;
if(hrs>40)
pay += hrate*(hrs-40);

return pay;



}
double taxfun(double grosspay1){
double rate;
double tax = rate*grosspay1;
if(grosspay1>=500)
rate =.1;
else if(grosspay1 >=200)
rate=.05;
else rate=0;
return tax;

}
Your using rate before assigning a value to it. It will contain random garbage from the stack.
Topic archived. No new replies allowed.