SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
5
Selecting Programming
Company

LOGO





Boolean Expression
If
Nested If
Switch…case
Boolean Expression







Comparison)
equal)
Not equal)
Less)
Greater)
Less than or equal to)



Greater than or equal

to)
X = 10 Y = "com")
X == 10
X != 10
X < 10
X > 10
X <= 10
X >= 10
y+"puter" == "computer"
Y == "Com"
Y != "com"

True
False
False
False
True
True
True
False
False
Boolean Expression



Boolean)
And)



Or)



Not)
A = 10,
B = 5, Y = "com", Z = true)
A == 10 && B+5 == A)
A + B > 10) && B == 5)
(B <= A) || (B == A)
!(10 == B)
!(A >= B)
(A == 10) && (Y == "com")
(Y == "Com") || (Y == "com")
(Y == "Com") || !(Z)
!(!(Z)) || !(Z)

True
False
True
True
False
True
True
False
True
True
If
If




condition)

If
if
if…else

True
else)

2

False
If
if (condition) statement;

(A=5, B=10)
If (A == B/2) Console.WriteLine("True");

if (condition)
statement;

If (B/2 == A)
Console.WriteLine(B+"/2 = " + A);

if (condition)
{
statement1;
statement2;
statement3;
:
}

If (A != B)
{
Console.WriteLine("A = {0}",A);
Console.WriteLine("B = {0}",B);
Console.WriteLine("{0} != {1}",A,B);
}
static void Main(string[] args)
{
int A = 5;
int B = 10;
if (A != B)
{
Console.WriteLine("A = {0}", A);
Console.WriteLine("B = {0}", B);
Console.WriteLine("{0} != {1}", A, B);
}
Console.ReadKey();
}
static void Main(string[] args)
{
char Member;
float Discount = 0f;
Console.Write("Are you Member (Y or N) : ");
Member = char.Parse(Console.ReadLine());
if ((Member == 'y') || (Member == 'Y'))
{
Discount = 0.05f;
}
Console.WriteLine("Discount is {0:p}",
Discount);
Console.ReadLine();
}
If…else
if (condition)
statement;
else
statement;
if (condition)
{
statement1;
statement2;
:
}
else
{
statement1;
statement2;
:
}

(A=5, B=10)
If (A == B)
Console.WriteLine(A+" = " + B);
else
Console.WriteLine(A+" != " + B);
If (A <= B)
{
Console.WriteLine("A = {0}",A);
Console.WriteLine("B = {0}",B);
Console.WriteLine("{0} <= {1}",A,B);
}
else
{
Console.WriteLine("A = {0}",A);
Console.WriteLine("B = {0}",B);
Console.WriteLine("{0} > {1}",A,B);
}
static void Main(string[] args)
{
int Age, Ticket;
Console.Write("How old are You? : ");
Age = int.Parse(Console.ReadLine());
if (Age >= 13)
{
Ticket = 50;
}
else
{
Ticket = 20;
}
Console.WriteLine("You are {0} years old",
Age);
Console.Write("The price of Ticket is "}
Console.Write("{0} Baht", Ticket);
Console.ReadLine();
}
Nested If
If
If

Nested If

If
Nested If

if (condition)
{
if (condition)
{
statement;
}
}

(A=13, B=60)
if (A == 13)
{
if (B == 60)
{
Console.WriteLine("A = {0} and B = {1}", A, B);
}
}
Nested If
if (condition)
{
if (condition)
{
statement;
}
}
else
{
if (condition)
{
statement;
}
}

(A=13, B=60)
if (salary < 1650)
{
SocialSecurity = 0;
}
else
{
if (salary < 15000)
{
SocialSecurity = salary * 0.05f;
}
else
{
SocialSecurity = 15000*0.05f;
}
}
Chapter05
5

A-F
50

If (Mark < 50)

F

60

If (Mark < 60)

D

70

If (Mark < 70)

C

80

If (Mark < 80)

B

A
80

If (Mark >= 80)

A

70

If (Mark >= 70)

B

60

If (Mark >= 60)

C

50

If (Mark >= 50)

D

F
Chapter05
Switch…case

C#

Nested if

switch...case
switch (expression)
{
case constant-expression-1:
statements;
break;
case constant-expression-2:
statements;
break;
case constant-expression-3:
statements;
break;
:
default:
statements;
break;
}

Switch…case

using System;
namespace SwitchCase
{
class Program
{
static void Main(string[] args)
{
char Operator;
int A = 5, B = 10, Total;
Operator = char.Parse(Console.ReadLine());
switch(Operator)
{
case '+': Total = A + B; break;
case '-': Total = A - B; break;
case '*': Total = A * B; break;
case '/': Total = A / B; break;
default: Total = 0; break;
}
Console.WriteLine("Answer is {0}", Total);
}
}
}
Switch…case

RAPTOR
default

If

If
switch…case
switch…case
char)

switch…case
If

integer)
string)
Try…catch


C#
Console.ReadLine()
int

int
int.Parse(Console.ReadLine())
A

try…catch…finally

A
int Operator = 0;
int A = 5, B = 10, Total;
try
{
Operator = int.Parse(Console.ReadLine());
}
catch (Exception)
{
Console.WriteLine("Input is not integer...Error!!!");
}
finally
{
Console.WriteLine("Write everytime");
}
try...catch...finally









Run Time Process)
Init Process)
Block
try
Block
catch
Block
finally

1 try

Block catch
Block
finally

try
1 Block



5

/

Weitere ähnliche Inhalte

Kürzlich hochgeladen

In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxAditiChauhan701637
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...Nguyen Thanh Tu Collection
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesCeline George
 
Work Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sashaWork Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sashasashalaycock03
 
10 Topics For MBA Project Report [HR].pdf
10 Topics For MBA Project Report [HR].pdf10 Topics For MBA Project Report [HR].pdf
10 Topics For MBA Project Report [HR].pdfJayanti Pande
 
EBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting BlEBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting BlDr. Bruce A. Johnson
 
Riddhi Kevadiya. WILLIAM SHAKESPEARE....
Riddhi Kevadiya. WILLIAM SHAKESPEARE....Riddhi Kevadiya. WILLIAM SHAKESPEARE....
Riddhi Kevadiya. WILLIAM SHAKESPEARE....Riddhi Kevadiya
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.raviapr7
 
3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptx3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptxmary850239
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICESayali Powar
 
How to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using CodeHow to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using CodeCeline George
 
Vani Magazine - Quarterly Magazine of Seshadripuram Educational Trust
Vani Magazine - Quarterly Magazine of Seshadripuram Educational TrustVani Magazine - Quarterly Magazine of Seshadripuram Educational Trust
Vani Magazine - Quarterly Magazine of Seshadripuram Educational TrustSavipriya Raghavendra
 
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRATanmoy Mishra
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfMohonDas
 
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptxSOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptxSyedNadeemGillANi
 
How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17Celine George
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17Celine George
 
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptxSlides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptxCapitolTechU
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...raviapr7
 

Kürzlich hochgeladen (20)

In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptx
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 Sales
 
Work Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sashaWork Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sasha
 
Prelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quizPrelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quiz
 
10 Topics For MBA Project Report [HR].pdf
10 Topics For MBA Project Report [HR].pdf10 Topics For MBA Project Report [HR].pdf
10 Topics For MBA Project Report [HR].pdf
 
EBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting BlEBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting Bl
 
Riddhi Kevadiya. WILLIAM SHAKESPEARE....
Riddhi Kevadiya. WILLIAM SHAKESPEARE....Riddhi Kevadiya. WILLIAM SHAKESPEARE....
Riddhi Kevadiya. WILLIAM SHAKESPEARE....
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.
 
3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptx3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptx
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICE
 
How to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using CodeHow to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using Code
 
Vani Magazine - Quarterly Magazine of Seshadripuram Educational Trust
Vani Magazine - Quarterly Magazine of Seshadripuram Educational TrustVani Magazine - Quarterly Magazine of Seshadripuram Educational Trust
Vani Magazine - Quarterly Magazine of Seshadripuram Educational Trust
 
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdf
 
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptxSOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
 
How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17
 
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptxSlides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...
 

Chapter05