SlideShare uma empresa Scribd logo
1 de 27
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;
}
}
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
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

/

Mais conteúdo relacionado

Último

會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
Financial Accounting IFRS, 3rd Edition-dikompresi.pdf
Financial Accounting IFRS, 3rd Edition-dikompresi.pdfFinancial Accounting IFRS, 3rd Edition-dikompresi.pdf
Financial Accounting IFRS, 3rd Edition-dikompresi.pdf
MinawBelay
 

Último (20)

會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
 
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
 
How to Analyse Profit of a Sales Order in Odoo 17
How to Analyse Profit of a Sales Order in Odoo 17How to Analyse Profit of a Sales Order in Odoo 17
How to Analyse Profit of a Sales Order in Odoo 17
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Software testing for project report .pdf
Software testing for project report .pdfSoftware testing for project report .pdf
Software testing for project report .pdf
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptx
 
Financial Accounting IFRS, 3rd Edition-dikompresi.pdf
Financial Accounting IFRS, 3rd Edition-dikompresi.pdfFinancial Accounting IFRS, 3rd Edition-dikompresi.pdf
Financial Accounting IFRS, 3rd Edition-dikompresi.pdf
 
The Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptxThe Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptx
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
 

Destaque

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Destaque (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Chapter05