before running program - fix warnings (and don't expect me to compile for you every time you make a small fix - this is one time offer since I'm really tired to see the same unfixed code again and again)
Code:
#include <iostream>
using namespace std;
int main()
{
int pass=123; int x; double overtime; double salary;
int hours; double hours_day; double night_hours; double holiday_hours;
cout<<"Program for payment (age under 25)\n";
Loop:
cout<<"Give password\n";
cin>>x;
if (x==pass){
cout<<"Give the hours you worked all month\n";
cin>>hours;//give 10
if (hours>176){
overtime=hours-176;
if (overtime<20)
overtime=((overtime*2.55)*0.20);
else if (overtime>20)
overtime=(((overtime-20)*2.55)*0.25)+((20*2.55)*0.20);
}
hours_day=(hours*2.55);
cout<<"Give how many night hours you worked\n";
cin>>night_hours;//give 0
cout<<"How many holiday hours you worked?\n";
cin>>holiday_hours;//give 0
salary=(hours_day+((night_hours*2.55)*0.25)+((holiday_hours*2.55)*0.75)+overtime);
cout<<"They must pay you "<<salary<<" euros"<<endl;
}
else{
cout<<"Wrong pass, try again \n";
goto Loop;
}
return 0;
}
Code:
g++ -c -o ../obj/test.o test.cpp -Wall -pedantic -std=c++0x -march=core2 -O2 -I../include
test.cpp: In function ‘int main()’:
test.cpp:27:90: warning: ‘overtime’ may be used uninitialized in this function [-Wuninitialized]
g++ -o test ../obj/test.o -Wall -pedantic -std=c++0x -march=core2 -O2 -I../include -lm