Reputation: 41
class calc_Payroll
private float hours;
private float rate;
private int hrsStr;
float gross;
calc_Payroll(float a, float b, float c, float d)
{
gross = hours + (hrsStr * 1.33) * rate; //error here
}
I'm confused as to where I have converted anything to a double? but the error I am getting is
cannot covert double to float
Upvotes: 0
Views: 148
Reputation: 393821
1.33
is a double
literal, and it causes the entire hours + (hrsStr * 1.33) * rate
expression to return a double
value, which can't be assigned to a float
variable without an explicit cast.
Change it to 1.33f
for a float
literal.
Upvotes: 4