Documente Academic
Documente Profesional
Documente Cultură
Question 1
A program was required to capture the meal orders of the Delphi students
attending the FunInTheSun workshop held recently in Utopia! Consider the
following Delphi code and the user interfaces presented.
Write the code for the procedure PlaceOrder. The number of meals and
the number of beverages must be passed as input parameters (integers),
and the cost of the order as well as the percentage of discount that was
given is retuned as output parameters from the procedure. (5)
1.2
Write
the
code
for
the
event
handler
procedure
TfrmMyProcMCQ.btnOrderClick(Sender: TObject); that includes the procedure
call : PlaceOrder(sedMeal.Value, sedBev.Value, rOrderCost, rOrderDiscount);
The results of the procedure call must be displayed in the ListBox. The results
of the previous order must first be cleared! (5)
1.3
Write the code for the event handler that resets the user interface. Note that
the last item in each of the RadioGroups must be selected by default. (2)
1.4
How would the program be modified to ensure that the student selects at least
one, but not more than 10 meals and at least one but not more than five
beverages? (3)
ForeignCurrency(StrToFloat(edtRand.Text),0.0873);
lblOtherCurrency.Caption := 'British pound';
end ;
procedure TfrmCurrencyCalculator.radAusDollarClick(Sender:
TObject);
begin
edtCurrency.Text :=
ForeignCurrency(StrToFloat(edtRand.Text),0.2397);
lblOtherCurrency.Caption := 'Australian dollar';
end;
2.1
Because only one value, the exchange amount, is returned from the subroutine.
2.2
What will the program do when a non-numeric value is entered into the Rand Edit
component? (1)
Re-write the event handler TfrmCurrencyCalculator.radEuroClick to handle nonnumeric values in the Rand Edit component by setting edtCurrencys Text
property to 0.00'. (4)
4.1
4.2
Write the code for the btnEnterRates that saves the exchange rate of the
selected currency. Note that this event must also clear the listing of the rates,
as well as the lblConverted.
4.3
Write the code for the btnShowRates event, that lists the currencies and the
exchange rates in the ListBox. The listbox should be cleared first though!
4.4
Write the code for the btnConvert that converts the amount in rand in the edit
box, according to the currency selected in the RadioGroup and the exchange
rate in the array. The result of the conversion must be displayed in the label
lblConverted.
4.5
Write the code that will execute when the user selects a different currency.
This must show a message in lblConverted label.
UNISA 2010