Originally Posted by
laserlight
Then you should try to come up with the smallest and simplest program that you expect should compile, but which demonstrates the error. For example:
Code:
int main()
{
int x = 1;
int y = 2;
int z;
x + y = z;
}
You will get a similiar error message. The reason is that the x + y subexpression results is a temporary value that is not an
lvalue, i.e., it cannot go on the
left hand side of an assignment expression.
Thank you I understand why that makes total sense now. I have another question as well I made some changes with declaring everything to the int which is probably all I will need, but for some reason my if else statements are not working correctly maybe its just the way I am coding them. Less than 40 hours doesnt give me any numbers and more than 40 hours only gives me the math for 40 hours any ideas why?
Code:
if (hours_worked < 40)
{
total_pay = hours_worked * hourly;
cout << "You need to work more hours! Your total pay is: $" << endl;
}
else if (hours_worked = 40)
{
total_pay = regular_pay * hourly;
cout << "Good job you worked 40 hours! Your pay is: $" << total_pay << endl;
}
else if (hours_worked > 40)
{
total_pay = hours_worked * hourly;
total_pay = regular_pay * hourly;
total_pay = (hours_worked - regular_pay) * 1.5 * hourly;
cout << "You worked an excessive amount of hours! Your total pay is: $" << total_pay << endl;
}
Output of less than 40 hours:
Code:
Please enter your first and last name:Joe
Please enter your hourly classifcation number 1 -5:
3
Please enter the amount of hours:
20
You are in classification 3 of employee pay
You need to work more hours! Your total pay is: $
Output of more than 40 hours:
Code:
Please enter your first and last name:Joe
Please enter your hourly classifcation number 1 -5:
5
Please enter the amount of hours:
50
You are in classification 5 of employee pay
Good job you worked 40 hours! Your pay is: $480