Im tryin to read the hours and payrate for 75 employees from a called file “employee.data” . This is what I have so far. Can anyone help me?
Code:
#include <iostream> #include <fstream> using namespace std; float grosspay(); float netpay(float); int main()// Starts the program { float gross=0;// Declares gross as a float int num = 1; // Declares num as a int float hours=0;// Declares hours as a float while(num<=4)// beginning of a while loop counts up to 4 { gross=grosspay();// Calls the function netpay(gross);// Calls the function } return 0; } float grosspay()// Begins the funtion outside of main { ifstream infile; infile.open("C:\Documents and Settings\dckorneg\Desktop"); float payrate;// Declares float hours;// Declares float gross;// Declares cout<< " Hello please Enter the employees payrate "<<endl;// Displays infile>>payrate;// Reads in cout<<" Hello please enter the amount of hoursworked"<<endl;//Displays infile>>hours;// Reads in gross = hours * payrate;// Formula cout<<" The grosspay for this employees is "<<gross<<endl;//Displays return gross; // Returns the value of gross } float netpay(float gross)// The function outside of main { float fedtaxes;// Declares as float float statetaxes;// Declares as float float netpay;//Declares as float float state = .06;// Declares as float float fed = .15;// Declares as float statetaxes = gross * state;// Formula fedtaxes = gross * fed;// Formula netpay = gross-statetaxes-fedtaxes;//Formula cout<<" This is your state taxes: "<<statetaxes<<endl;// Displays cout<<" This is your federal taxes: "<<fedtaxes<<endl;// Displays cout<<" This is your netpay: "<<netpay<<endl;// Displays return netpay; }
Comment