☰ Contents · Computing

Changing the data type and a test

Lessons 49–50 · 2 lessons · N. I. Taylaqov (general editor), A. B. Akhmedov, M. D. Pardayeva, A. A. Abdug‘aniyev, U. M. Mirsanov. Informatics and Information Technologies, Grade 10, 1st edition. “Extremum-Press”, Tashkent, 2017
50

Test work

Textbook: p. 110
GoalCompletes a test variant on lessons 43–49 of the Delphi chapter: Label, Visible/Enabled, Edit and changing types.
New words
test: a checking work on a finished topic · nazoratcode analysis: reading code and predicting its result · kod tahliliapplication design: planning objects, properties and events · ilova yaratishchecking: comparing the result with a hand calculation · tekshirish
Explanation

The test contains three kinds of tasks: a theory question (for example about the properties of Label, Edit and Button), code analysis (working out what result a given procedure gives) and creating a new application. In code analysis write the values of the variables step by step in a table: this prevents mistakes. When creating a new application plan first what will be on the window (how many Labels, Edits, Buttons), then their properties, then the button procedure. Where text and numbers are mixed, check whether StrToInt, IntToStr, StrToFloat or FloatToStr is needed. Test the application with F9 and also see how it behaves with at least one wrong entry.

Worked examples
Code analysis: var s, i: Integer; ⏎ begin ⏎  s := 0; ⏎  for i := 1 to 4 do ⏎    s := s + i * 2; ⏎  Label1.Caption := IntToStr(s); ⏎ end; Steps: i = 1: s = 2; i = 2: s = 6; i = 3: s = 12; i = 4: s = 20. The Label shows 20.
Creating an application: “Triangle perimeter”. Three Edits (a, b, c), one button, one Label. The button procedure: Label1.Caption := 'P = ' + IntToStr(StrToInt(Edit1.Text) + StrToInt(Edit2.Text) + StrToInt(Edit3.Text)); with 3, 4, 5 it gives P = 12.
Class activity

“Reading code”: a pair writes a short procedure for each other; the second finds the result with a table and checks it in the application.

Practice
1
After s := 0; for i := 1 to 3 do s := s + i * 3; what is s?
2
If a = 6, b = 8, c = 10, what is the perimeter of the triangle?
3
What is used to convert the number in an Edit to an integer?
4
Why is it useful to write the variable values in a table in code analysis?