I need to make a program that works out the amount you will get paid for the hours you worked. Here\'s the code:
unit HoursWorked_u;
interface
uses
Windo
The error is here:
iHours := sedHours.value * rPay;
The right hand side is a floating point expression because rPay
is a floating point variable. You cannot assign a floating point value to an integer. You need to convert to an integer.
For instance, you might round to the nearest:
iHours := Round(sedHours.value * rPay);
Or you might use Floor
to get the largest integer less than or equal to the floating point value:
iHours := Floor(sedHours.value * rPay);
Or perhaps Ceil
, the smallest integer greater than or equal to the floating point value:
iHours := Ceil(sedHours.value * rPay);
For some more general advice I suggest that you try to look in the documentation when you encounter an error that you do not understand. Every compiler error is documented. Here's the documentation for E2010 Incompatible types: http://docwiki.embarcadero.com/RADStudio/en/E2010_Incompatible_types_-_%27%25s%27_and_%27%25s%27_%28Delphi%29
Take a good read of it. Although the example given is not an exact match for your case it is very close. Compiler errors are not things to be scared of. They come with descriptive text and you can solve your problem by reading them and trying to work out how your code has led to the particular error.