Jan 5, 2015 at 6:55am UTC
can somebody tell me whats wrong with my program ?
it always says that coundnt find match operator ?
what can i do ?
i want to multiply string pay to int HOURS
thanks a lot
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main () {
system("color 8e");
string ID,name, address,No, pos ,pay, hanap;
string hours;
string ot;
string a , b,c,d,e,f,g,h,i,j,k,l;
ifstream OMG;
OMG.open("Employee.txt", ios::in );
cout << "Enter employee ID you want to search: ";
cin >> hanap;
while (getline(OMG, ID, ','),
getline(OMG, name, ','),
getline(OMG, address, ','),
getline(OMG, No, ','),
getline(OMG, pos, ','),
getline(OMG, pay, '\n'))
if (hanap == ID){
cout << "\nID: " << ID << endl;
cout << "Name: " << name << endl;
cout << "Adress: " << address << endl;
cout << "Contact No: " << No << endl;
cout << "Position: " << pos << endl;
cout << "Pay: "<< pay <<endl;
cout << "****************************\n";
cout << " EARNINGS "<<endl;
cout << "No of Hrs Work : ";
cin >> hours;
cout << "OT hours work : ";
cin >> ot;
cout << "*****************************\n";
cout << " DEDUCTIONS "<<endl;
cout << "Tax: "<<endl;
cout <<"SSS: "<<endl;
cout <<"PhilHealth: "<<endl;
cout << "*****************************\n";
cout << " SUMMARY "<<endl;
cout << "Gross Income: "<<pay * hours<<endl;
cout << "Net Income: "<<endl;
}
OMG.close();
system("pause");
}
Last edited on Jan 5, 2015 at 7:28am UTC
Jan 6, 2015 at 6:32am UTC
@bugbyte sir ? where should i put that ?
Jan 6, 2015 at 9:36am UTC
where ever you want to calculate with int values in strings. Who should know better than you? Maybe here?
cout << "Gross Income: " << stoi(pay) * stoi(hours) << '\n' ;
Maybe I should add, you should validate input before processing it.
Last edited on Jan 6, 2015 at 9:37am UTC