我需要编写一个程序来计算你工作的小时数所得到的支付金额。
以下是代码:
unit HoursWorked_u;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Spin;
type
TForm1 = class(TForm)
lblName: TLabel;
edtName: TEdit;
Label1: TLabel;
sedHours: TSpinEdit;
btncalc: TButton;
Panel1: TPanel;
lblOutput: TLabel;
Label2: TLabel;
Panel2: TPanel;
lblOutPutMonth: TLabel;
labelrandom: TLabel;
Label3: TLabel;
seddays: TSpinEdit;
procedure btncalcClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
// sedHours and sedDays are SpinEdits
// Rand (R) is South African currency eg: One months work, I will recieve-
// -R10 000.00
// Where R12,50 is paid an hour.
// Need to work out how much I will get paid for how many hours are worked.
procedure TForm1.btncalcClick(Sender: TObject);
var
sName :string;
iHours, iDays :integer;
rPay :real;
begin
rPay := 12.5;
sName := edtName.Text;
iHours := sedHours.value * rPay;
iDays := sedDays.value * iHours;
lblOutput.caption := sName + ' You will recieve R' + IntToStr (iHours);
lblOutputMonth.Caption := 'You will recive R' + intToStr (iDays);
end;
end.
错误信息如下:
[Error] HoursWorked_u.pas(51): Incompatible types: 'Integer' and 'Extended'
请注意:我完全是一个编码的新手,这是IT作业。 非常感谢任何帮助! 提前致谢!