I'm getting a comparison b/w pointer and inter error and not sure where the problem is.
#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
main(){
int id[5], hw[5];
float hr[5], oth[5], otp[5], rgp[5], gp[5], tax[5], np[5], TAXR[5];
char fname[5][15], lname[5][15], ms[1][5];
int counter=0;
int i;
ifstream fin("payrollfl.txt");
while(fin>>fname[counter]>>lname[counter]>>id[counter]>>hw[counter]>>hr[counter]>>ms[counter]){
counter=counter+1;
if(hw[i]>40){
oth[i]=hw[i]-40;
otp[i]=oth[i]*hr[i]*1.5;
rgp[i]=hw[i]*hr[i];
}//IF
else{
oth[i]=0;
otp[i]=0;
rgp[i]=hw[i]*hr[i];
}//ELSE
gp[i]=rgp[i]+otp[i];
if ((gp[i]>1000) && ms[i]=='S'||ms[i]=='s') TAXR[i]=0.35;
else if ((gp[i]>1000) && ms[i]=='M'||ms[i]=='m') TAXR[i]=0.30;
else if ((gp[i]>1000) && ms=[i]='H'||ms[i]=='h') TAXR[i]=0.25;
else if ((gp[i]>800) && ms[i]=='S'||ms[i]=='s') TAXR[i]=0.25;
else if ((gp[i]>800) && ms[i]=='M'||ms[i]=='m') TAXR[i]=0.20;
else if ((gp[i]>800) && ms[i]=='H'||ms[i]=='H') TAXR[i]=0.15;
else if ((gp[i]>500) && ms[i]=='S'||ms[i]=='s') TAXR[i]=0.15;
else if ((gp[i]>500) && ms[i]=='M'||ms[i]=='m') TAXR[i]=0.10;
else if ((gp[i]>500) && ms[i]=='H'||ms[i]=='h') TAXR[i]=0.05;
else TAXR[i]=0.0;
tax[i]=gp[i]*TAXR[i];
np[i]=gp[i]-tax[i];
cout<<fixed;
cout<<setw(15)<<"FIRST NAME"<<setw(15)<<"LAST NAME"<<setw(12)<<"EMPLOYEE ID"<<setw(4)<<"HW"<<setw(6)<<"HRRATE"<<setw(8)<<"M STATUS"<<setw(4)<<"OVHR"<<setw(7)<<"OVPAY"<<setw(7)<<"REG PAY"<<setw(9)<<"GROSS PAY"<<setw(9)<<"TAXAMOUNT"<<setw(7)<<"NET PAY"<<endl<<endl;
for(i=0;i<counter;i++){
cout<<setw(15)<<fname[i]<<setw(15)<<lname[i]<<setw(12)<<id[i]<<setw(4)<<hw[i]<<setw(6)<<hr[i]<<setw(8)<<ms[i]<<setw(4)<<oth[i]<<setw(7)<<otp[i]<<setw(7)<<rgp[i]<<setw(9)<<gp[i]<<setw(9)<<tax[i]<<setw(7)<<np[i]<<endl;
}//FOR
system("pause");
}//WHILE
return 0;
}//main
The error is showing up on line 25-33(my if statements on TAXR). Can someone point me in the right direction to clear this up. It would be much appreciated.
Nevermind on that error, different problem now. revised is as follows .
#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
main(){
int id, hw;
float hr, oth, otp, rgp, gp, tax, np, TAXR;
char fname[15], lname[15], ms;
ifstream fin("payrollfl.txt");
setiosflags(ios::fixed|ios::showpoint|ios::left);
cout<<setw(11)<<"FIRST NAME"<<setw(11)<<"LAST NAME"<<setw(11)<<"EMPLOYEE ID"<<setw(3)<<"HW"<<setw(6)<<setprecision(2)<<"HR"<<setw(4)<<"STAT"<<setw(4)<<"OTH"<<setw(7)<<setprecision(2)<<"OTP"<<setw(7)<<setprecision(2)<<"REGP"<<setw(9)<<setprecision(2)<<"GROSS"<<setw(7)<<setprecision(2)<<"TAX"<<setw(7)<<setprecision(2)<<"NET"<<endl<<endl;
while(fin>>fname>>lname>>id>>hw>>hr>>ms){
if(hw>40){
oth=hw-40;
otp=oth*hr*1.5;
rgp=hw*hr;
}//IF
else{
oth=0;
otp=0;
rgp=hw*hr;
}//ELSE
gp=rgp+otp;
if ((gp>1000) && ms=='S'||ms=='s') TAXR=0.35;
else if ((gp>1000) && ms=='M'||ms=='m') TAXR=0.30;
else if ((gp>1000) && ms=='H'||ms=='h') TAXR=0.25;
else if ((gp>800) && ms=='S'||ms=='s') TAXR=0.25;
else if ((gp>800) && ms=='M'||ms=='m') TAXR=0.20;
else if ((gp>800) && ms=='H'||ms=='H') TAXR=0.15;
else if ((gp>500) && ms=='S'||ms=='s') TAXR=0.15;
else if ((gp>500) && ms=='M'||ms=='m') TAXR=0.10;
else if ((gp>500) && ms=='H'||ms=='h') TAXR=0.05;
else TAXR=0.0;
tax=gp*TAXR;
np=gp-tax;
cout<<fixed;
setiosflags(ios::fixed|ios::left);
cout<<setw(11)<<fname<<setw(11)<<lname<<setw(11)<<id<<setw(3)<<hw<<setw(6)<<hr<<setw(4)<<ms<<setw(4)<<oth<<setw(7)<<otp<<setw(7)<<rgp<<setw(9)<<gp<<setw(7)<<tax<<setw(7)<<np<<endl;
}//WHILE
system("pause");
return 0;
}//main
It complies fine. The output needs to be refined.
ios::left i thought would set the data to the left but it didn't .
is there something wrong with that line or is it a bug with the compiler.
error: ISO C++ forbids declaration of 'main' with no type
It should be int main()
warning: suggest parentheses around && within ||
The && operator has a higher precedence than ||, so your if statements aren't doing what you think they are. Use parentheses: if ((gp>100) && ((ms=='S') || (ms=='s'))) ...
I tend to think it is a good idea to use parentheses liberally.
error: 'system' was not declared in this scope
Your compiler may accept that, but many won't. If you plan to use a function make sure to include the proper header. (#include <cstdlib> for system().)