List Box and Exercises: If Ubaya (Infor+Sib+Mm+Itdd)
List Box and Exercises: If Ubaya (Infor+Sib+Mm+Itdd)
IF UBAYA (Infor+SIB+MM+ITDD)
REVIEW OF DATA TYPES
• Previously you’ve learnt three data types in C#. They are:
s...... to represents Text
i...... to represents whole number, and
d..... to represents floating point or fractional number
• When two data types that are involved in the expression or
assignment statement are not the same, we have to eq.......... the
data types
• C# can do this automatically to convert:
i.... : To double,
2
5
BEFORE EXECUTING LINE FIRSTNUM
• The yellow line shows that the
code HAS NOT BEEN processed
(you can press F10 to process it)
• In this case, we can see that
before that line is processed,
the content of:
• The variable firstNum is still 0
• The Text property of
textBoxFirstNumber contains
“20” ( not 20 ! ) 6
BEFORE EXECUTING LINE SECONDNUM
• Now after executing firstNum
line, we can see that
• The variable firstNum now contains
20 (int.Parse changes “20” to 20)
• The Text property of
textBoxFirstNumber still contains
“20”
What is the content of secondNum and textBoxSecondNumber.Text after that line is executed?
THE CONTENT OF VARIABLES
• What is the content of the
following variables and the
Text property, when the
process has come to the end
of the program?
• firstNum
• secondNum
• resultPlus
• textBoxFirstNumber.Text
• textBoxSecondNumber.Text
8
• labelShowResult.Text
EXERCISES
9
RESTAURANT BILL CALCULATOR
Project Name: Your First Name – BillCalculator
the example input and output in the user interface in slide #13
USER INTERFACE AND THE REQUIREMENTS
• User Interface at Design time • When it is run at the first time
13
EXERCISE #2
CURRENCY CALCULATOR
14
CURRENCY CALCULATOR
Project Name: YourFirstName – Currency Calculator
16
WHEN THE USER CHANGES THE CURRENCY
19
WHEN THE USER CLICKS CLEAR ALL BUTTON
20
RESTAURANT BILL CALCULATOR
THE FORMULA
Notes: it is assumed that all variables with the names preceded by the word21
“percent” contain a percentage number that have not been divided by 100
(for example it contains 20 to represent 20%)