Kód:
class TForm1 : public TForm 
{ 
__published: // IDE-managed Components 
TEdit *Edit1; 
TEdit *Edit2; 
TEdit *Edit3; 
TButton *Button1; 
TLabel *Label1; 
TLabel *Label2; 
TLabel *Label3; 
TMainMenu *MainMenu1; 
TMenuItem *Monosti1; 
TMenuItem *Konec1; 
TMenuItem *Oprograme1; 
TButton *Button2; 
void __fastcall Button1Click(TObject *Sender); 
void __fastcall Oprograme1Click(TObject *Sender); 
void __fastcall Konec1Click(TObject *Sender); 
void __fastcall Button2Click(TObject *Sender); 
private: // User declarations 
public: // User declarations 
__fastcall TForm1(TComponent* Owner); 
}; 
//--------------------------------------------------------------------------- 
extern PACKAGE TForm1 *Form1; 
//--------------------------------------------------------------------------- 
class TSpotreba 
{ 
public: 
double Spalene_litre, Dlzka_cesty, Visledok; 
TSpotreba(double SSpalene_litre, double DDlzka_cesty, double VVisledok); 
}; 
#endif 

Unit1.cpp 

__fastcall TForm1::TForm1(TComponent* Owner) 
: TForm(Owner) 
{ 
} 
//--------------------------------------------------------------------------- 
TSpotreba::TSpotreba(double SSpalene_litre, double DDlzka_cesty, double VVisledok) 
{ Spalene_litre = SSpalene_litre; 
Dlzka_cesty = DDlzka_cesty; 
Visledok = VVisledok; 
} 
//--------------------------------------------------------------------------- 
void __fastcall TForm1::Button1Click(TObject *Sender) 
{ TSpotreba *Vypocet; 
while (Edit1->Text, Edit2->Text != "0", "" ) 

Vypocet = new TSpotreba(Edit1->Text.ToDouble(), Edit2->Text.ToDouble(), 
(Edit1->Text.ToDouble() / Edit2->Text.ToDouble()) *100); 
Edit3->Text = FloatToStr(Vypocet->Visledok); 

ShowMessage("Priemerná spotreba paliva na 100 kilometrov je " + FloatToStr(Vypocet->Visledok) + " litrov."); 

} 
//--------------------------------------------------------------------------- 
void __fastcall TForm1::Konec1Click(TObject *Sender) 
{ 
Application->Terminate(); 
} 
//--------------------------------------------------------------------------- 

void __fastcall TForm1::Button2Click(TObject *Sender) 
{ 
Edit3->Clear(); 
}