c++ - My code is returning two really weird errors -
my code isn't working. don't know why. errors getting don't make sense.
17 18 c:\users\the beast\desktop\case study phase 3.0.6.cpp [error] function-definition not allowed here before '{' token
i dont know why throwing error.
77 1 c:\users\the beast\desktop\case study phase 3.0.6.cpp [error] expected '}' @ end of input
^ brackets present checked no idea why throwing error
#include<iostream> #include<fstream> #include<string> #include<cstdlib> using namespace std; //loading libraries float const taxnet = .9; float const taxwh = .1; float employeenumber; float payrate=0; float gross=0; float net=0; float manhours=0; float overtime=0; float taxes=0; char usercontrols; void data_loop(char usercontrols); void writeworkerinfo(ofstream &stream, float employeenumber, float manhours, float payrate, float gross, float taxes, float net); void payrollcalc(float employeenumber, float manhours, float payrate, float gross, float taxes, float net); void data_entry(float employeenumber, float manhours, float payrate); void data_recall(float employeenumber); void data_error_check(char usercontrols); int main(){ // varibles cout << "hit 1 enter new data; hit 2 load file; hit escpae exit." << endl; cin >> usercontrols; while (usercontrols != 27){ data_error_check(usercontrols); } return 0; } void data_error_check(char usercontrols){ cin >> usercontrols; if(usercontrols == 49 || 50){ data_loop(usercontrols); } else if (usercontrols != 49 ||50){ cout << "wrong button hit enter return main menu" << end; cin >> usercontols; if(usercontrols == 13){ main(); } } } void data_loop(char usercontrols){ cin >> usercontrols; if (usercontrols == 49){ data_entry(); } else(usercontrols == 50){ data_recall(); } } void writeworkerinfo(ofstream &stream, float employeenumber, float manhours, float payrate, float gross, float taxes, float net){ stream << " id " << employeenumber << endl; stream << " # of hours worked " << manhours << endl; stream << " hourly rate " << payrate << endl; stream << " gross pay " << gross << endl; stream << " tax rate " << taxwh << endl; stream << " amount of taxes " << taxes << endl; stream << " net pay " << net << endl; data_loop(); } void payrollcalc(float employeenumber, float manhours, float payrate, float gross, float taxes, float net){ if (manhours > 40) { overtime = manhours - 40; gross = ((manhours - overtime) * payrate) + ((payrate * 1.5)* overtime); //overtime claculation } else { gross = manhours * payrate; //no overtime calculation } taxes = gross * taxwh; net = gross * taxnet; //writeworkerinfo(float employeenumber,float manhours,float payrate,float gross,float taxwh,float taxes,float net); std::string empnum = std::to_string(employeenumber); ofstream payroll; payroll.open(empnum + ".txt"); writeworkerinfo(float employeenumber,float manhours,float payrate,float gross,float taxes,float net); payroll.close(); } void data_entry(float employeenumber,float manhours,float payrate){ cout << "enter employee id:"; cin >> employeenumber; cout << "enter number of hours worked:"; cin >> manhours; cout << "enter pay rate:"; cin >> payrate; payrollcalc(); } void data_recall(float employeenumber){ cout << "enter employee number"; cin >> employeenumber; ///reading in data std::string empnum = std::to_string(employeenumber); ofstream payroll; payroll.open(empnum + ".txt"); payroll.close(); data_loop(); }
just functions definitions out of main
block code , call them inside main
Comments
Post a Comment