Can you tell me what's wrong with it because it's not running on visual studio and I need it right now???
#include <iostream>
#include<vector>
#include<algorithm>
#include<limits>
#include<fstream>
#include<string>
using namespace std;
class PayRoll
{
private:
vector<int> salaries;
public:
PayRoll();
bool searchSalary(int salary);
void generateStats();
void printSalaries();
};
PayRoll::PayRoll()
{
ifstream in("newdata.txt");
if(!in.good())
{
cout<<"Sorry Data File is not Found"<<endl;
exit(1);
}
else
{ string str;
while(!in.eof())
{
in>>str;
int temp = atoi(str.c_str());
salaries.push_back(temp);
}
}
}
bool PayRoll::searchSalary(int salary)
{
return (find(salaries.begin(),salaries.end(),salary) != salaries.end());
}
void PayRoll::generateStats()
{
int minimumSalary = numeric_limits<int>::max();
int maximumSalary = numeric_limits<int>::min();
for(vector<int>::const_iterator iter = salaries.begin();iter<salaries.end();iter++)
{
if(*iter<minimumSalary) minimumSalary = *iter;
if(*iter>maximumSalary) maximumSalary = *iter;
}
ofstream out("stats.txt");
out<<"Minimum Salary is: "<<minimumSalary<<endl;
out<<"Maximum Salary is: "<<maximumSalary<<endl;
}
void PayRoll::printSalaries()
{
for(vector<int>::const_iterator iter = salaries.begin();iter<salaries.end();iter++)
{
cout<<(*iter)<<endl;
}
}
int main() {
PayRoll payroll;
int selection;
do
{
cout<<"Search Salary, Enter 1"<<endl;
cout<<"Generates Stats file, Enter 2"<<endl;
cout<<"Print Salaries, Enter 3"<<endl;
cout<<"Quit, Enter 4"<<endl;
cin>>selection;
switch(selection)
{
case 1:
int tempSalary;
cout<<"Enter Salary to search: "<<endl;
cin>>tempSalary;
if(payroll.searchSalary(tempSalary)) cout<< "Salary Found "<<endl;
else cout<<"Salary not found"<<endl;
break;
case 2:
payroll.generateStats();
break;
case 3:
payroll.printSalaries();
break;
case 4:
break;
default:
cout<<"Enter a valid Selection"<<endl;
break;
}
}while(selection != 4);
return 0;
}