SlideShare uma empresa Scribd logo
1 de 9
Basic Scientific Programming
Case Statement
The Case Construct


Used in cases where exactly one of several alternative actions is
selected and performed.

form
Select Case(Selector)
case(label-list1)
statement sequence1
case(label-list2)
statement sequence2
“
case(label-list n)
statement sequence n
End select




Selector is an integer, character, or logical
expression.
The values in the list may have any of the forms:
(value)
single value
(value1: value2) range of values from value1 through
value2.
(value1:)
range of values greater than or equal
to value1
(: value2)
range of values less than or equal to
value2
Example


Select Case(Class_Code)
Case(1)
print*,’Freshman’
Case(2)
print*,’Sophomore’
Case(3)
print*,’Junior’
Case(4)
print*,’Senior’
Case Default
print*, ‚error,Illegal code‛
End Select
Example: Pollution Index




A case statement can be used to carry
out the classification given (good, fair,
or poor).
A case statement can be used to
replace an IF / ELSE IF structure.
Range Selectors “Integers”


Select Case(Int(average))
case(90:)
grade = ‚A‛
case(80:89)
grade = ‚B‛
case(70:79)
grade = ‚C‛
case(60:69)
grade = ‚D‛
case(:59)
grade = ‚F‛
End Select
Range Selectors “Characters”


Select Case(char)
case(‘A’: ‘Z’)
Print*, ‘uppercase’
case(‘a’: ’z’)
Print*, ‘lowercase’
case(‘0’:’9’)
Print*, ‘numbers’
case default
Print*, ‘Not a letter or number’
End Select
What about real valued selectors??




A selector can’t be of type real.
To make a selection, convert the real
number to an integer and then use it
for the selection.
example
Suppose a motors’ RPM is determined by an indicator x.
 high speed
x>= 5.5
 normal speed 2.5<= x < 5.5
 Low speed
x < 2.5
Select Case(int(10*x))

case(55:)
print*, ‚HIGH SPEED‛
case(25:54)
print*, ‚NORMAL SPEED‛
case(:24)
print*, ‚LOW SPEED‛
End Select

Mais conteúdo relacionado

Mais procurados

Excel functions formulas
Excel functions formulasExcel functions formulas
Excel functions formulas
LearnIT@UD
 
اىفناىنمفبانفيا
اىفناىنمفبانفيااىفناىنمفبانفيا
اىفناىنمفبانفيا
Bisan Rjoub
 

Mais procurados (16)

ASNP
ASNPASNP
ASNP
 
Logistic regression
Logistic regressionLogistic regression
Logistic regression
 
June 2015
June 2015June 2015
June 2015
 
Excel functions formulas
Excel functions formulasExcel functions formulas
Excel functions formulas
 
spss teaching
spss teachingspss teaching
spss teaching
 
SPSS How to use Spss software
SPSS How to use Spss softwareSPSS How to use Spss software
SPSS How to use Spss software
 
اىفناىنمفبانفيا
اىفناىنمفبانفيااىفناىنمفبانفيا
اىفناىنمفبانفيا
 
Spss basics tutorial
Spss basics tutorialSpss basics tutorial
Spss basics tutorial
 
SPSS-SYNTAX
SPSS-SYNTAXSPSS-SYNTAX
SPSS-SYNTAX
 
Tutorial of SPSS
Tutorial of SPSSTutorial of SPSS
Tutorial of SPSS
 
An Introduction to SPSS
An Introduction to SPSSAn Introduction to SPSS
An Introduction to SPSS
 
Practice Test 5B Multinomial Experiments and Contingency Tables
Practice Test 5B Multinomial Experiments and Contingency TablesPractice Test 5B Multinomial Experiments and Contingency Tables
Practice Test 5B Multinomial Experiments and Contingency Tables
 
RSS 2012 Data Entry SPSS
RSS 2012 Data Entry SPSSRSS 2012 Data Entry SPSS
RSS 2012 Data Entry SPSS
 
AMOS tutorial (Estimated Effect in AMOS)
AMOS tutorial (Estimated Effect in AMOS)AMOS tutorial (Estimated Effect in AMOS)
AMOS tutorial (Estimated Effect in AMOS)
 
Evaluation of multilabel multi class classification
Evaluation of multilabel multi class classificationEvaluation of multilabel multi class classification
Evaluation of multilabel multi class classification
 
Comparison statisticalsignificancetestir
Comparison statisticalsignificancetestirComparison statisticalsignificancetestir
Comparison statisticalsignificancetestir
 

Destaque

9 bí quyết học giỏi của các sinh viên Mỹ
9 bí quyết học giỏi của các sinh viên Mỹ9 bí quyết học giỏi của các sinh viên Mỹ
9 bí quyết học giỏi của các sinh viên Mỹ
phamhuytranlinh840836
 
9 f = 3 julianto arif setiadi bahrul ulum
9 f = 3 julianto arif setiadi   bahrul ulum9 f = 3 julianto arif setiadi   bahrul ulum
9 f = 3 julianto arif setiadi bahrul ulum
Eka Dhani
 
9.geo sorumluluk
9.geo sorumluluk9.geo sorumluluk
9.geo sorumluluk
matiz-4
 
9. b.n.septiembre 2013
9. b.n.septiembre 20139. b.n.septiembre 2013
9. b.n.septiembre 2013
colegionusefa
 
9 infidelidad peligro y prevencion
9 infidelidad peligro y prevencion9 infidelidad peligro y prevencion
9 infidelidad peligro y prevencion
Andy Esqueche
 
第9讲 Eigrp
第9讲 Eigrp第9讲 Eigrp
第9讲 Eigrp
F.l. Yu
 
9 EXPLANATION\MEANING OF PRATIKRAMANA SUTRAS VARAKANAKA STUTI, SHRI BHAVANA ...
9 EXPLANATION\MEANING OF PRATIKRAMANA SUTRAS  VARAKANAKA STUTI, SHRI BHAVANA ...9 EXPLANATION\MEANING OF PRATIKRAMANA SUTRAS  VARAKANAKA STUTI, SHRI BHAVANA ...
9 EXPLANATION\MEANING OF PRATIKRAMANA SUTRAS VARAKANAKA STUTI, SHRI BHAVANA ...
mehtavikas99
 
9 discapacidad visual sesion 9 de 14
9 discapacidad visual sesion 9 de 149 discapacidad visual sesion 9 de 14
9 discapacidad visual sesion 9 de 14
Armando Gr
 

Destaque (20)

9. impresiones 3d
9. impresiones 3d9. impresiones 3d
9. impresiones 3d
 
«Перспективы и тенденции продвижения поведенческими факторами в 2015 году», К...
«Перспективы и тенденции продвижения поведенческими факторами в 2015 году», К...«Перспективы и тенденции продвижения поведенческими факторами в 2015 году», К...
«Перспективы и тенденции продвижения поведенческими факторами в 2015 году», К...
 
9 bí quyết học giỏi của các sinh viên Mỹ
9 bí quyết học giỏi của các sinh viên Mỹ9 bí quyết học giỏi của các sinh viên Mỹ
9 bí quyết học giỏi của các sinh viên Mỹ
 
9 f = 3 julianto arif setiadi bahrul ulum
9 f = 3 julianto arif setiadi   bahrul ulum9 f = 3 julianto arif setiadi   bahrul ulum
9 f = 3 julianto arif setiadi bahrul ulum
 
9.geo sorumluluk
9.geo sorumluluk9.geo sorumluluk
9.geo sorumluluk
 
9 frame sequence
9 frame sequence9 frame sequence
9 frame sequence
 
9. environmental health and toxicology
9. environmental health and toxicology9. environmental health and toxicology
9. environmental health and toxicology
 
9.estandares superior ebr_peru
9.estandares superior ebr_peru9.estandares superior ebr_peru
9.estandares superior ebr_peru
 
9. b.n.septiembre 2013
9. b.n.septiembre 20139. b.n.septiembre 2013
9. b.n.septiembre 2013
 
9febbraio2013
9febbraio20139febbraio2013
9febbraio2013
 
9 infidelidad peligro y prevencion
9 infidelidad peligro y prevencion9 infidelidad peligro y prevencion
9 infidelidad peligro y prevencion
 
Nove 'coisas' que desaparecerão
Nove 'coisas' que desaparecerão Nove 'coisas' que desaparecerão
Nove 'coisas' que desaparecerão
 
第9讲 Eigrp
第9讲 Eigrp第9讲 Eigrp
第9讲 Eigrp
 
9.El método científico
9.El método  científico9.El método  científico
9.El método científico
 
Appcelerator Titanium Alloy + Kinvey Collection Databinding - Part One
Appcelerator Titanium Alloy + Kinvey Collection Databinding - Part OneAppcelerator Titanium Alloy + Kinvey Collection Databinding - Part One
Appcelerator Titanium Alloy + Kinvey Collection Databinding - Part One
 
9 EXPLANATION\MEANING OF PRATIKRAMANA SUTRAS VARAKANAKA STUTI, SHRI BHAVANA ...
9 EXPLANATION\MEANING OF PRATIKRAMANA SUTRAS  VARAKANAKA STUTI, SHRI BHAVANA ...9 EXPLANATION\MEANING OF PRATIKRAMANA SUTRAS  VARAKANAKA STUTI, SHRI BHAVANA ...
9 EXPLANATION\MEANING OF PRATIKRAMANA SUTRAS VARAKANAKA STUTI, SHRI BHAVANA ...
 
9 discapacidad visual sesion 9 de 14
9 discapacidad visual sesion 9 de 149 discapacidad visual sesion 9 de 14
9 discapacidad visual sesion 9 de 14
 
Generació automàtica d'informació de línies de transport
Generació automàtica d'informació de línies de transportGeneració automàtica d'informació de línies de transport
Generació automàtica d'informació de línies de transport
 
9. Pilot models of onion cultivation for adaptation to drought and salinity
9. Pilot models of onion cultivation for adaptation to drought and salinity9. Pilot models of onion cultivation for adaptation to drought and salinity
9. Pilot models of onion cultivation for adaptation to drought and salinity
 
9.EOS070529
9.EOS0705299.EOS070529
9.EOS070529
 

Mais de fyjordan9

Mais de fyjordan9 (16)

17recursion
17recursion17recursion
17recursion
 
16 subroutine
16 subroutine16 subroutine
16 subroutine
 
15 functions
15 functions15 functions
15 functions
 
14 arrays
14 arrays14 arrays
14 arrays
 
13 arrays
13 arrays13 arrays
13 arrays
 
12 doloops
12 doloops12 doloops
12 doloops
 
11 doloops
11 doloops11 doloops
11 doloops
 
10 examples for if statement
10 examples for if statement10 examples for if statement
10 examples for if statement
 
7 files
7 files7 files
7 files
 
6 read write
6 read write6 read write
6 read write
 
5 format
5 format5 format
5 format
 
4 design
4 design4 design
4 design
 
3 in out
3 in out3 in out
3 in out
 
2 int real
2 int real2 int real
2 int real
 
1 arithmetic
1 arithmetic1 arithmetic
1 arithmetic
 
PHYS303
PHYS303PHYS303
PHYS303
 

Último

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 

Último (20)

Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 

9 case