【发布时间】:2025-11-24 11:40:02
【问题描述】:
我需要制定一个程序,计算出您在工作时数中将获得的报酬。 代码如下:
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 作业。 任何帮助将非常感激! 提前致谢!
【问题讨论】:
-
在您的最后一个问题中,我说:当您显示错误消息时,请确保我们可以将消息中的行号与您提供的代码结合起来。 请请注意这个建议。
标签: delphi