SlideShare uma empresa Scribd logo
1 de 8
Task 1
In the first of today’s lessons your will
need to complete your GUI work and
upload it.

Once you have done this you will be
working through the Greenfoot
tutorials.
Learning outcomes

By the end of today’s lesson;
• All of you will create basic Switch
  Cases
• Most of you will ensure all the syntax
  is correct for your Switch Cases
• Some of you will create a detailed
  Switch Case which includes Strings
The Selection Constructs
When we want to perform a check in Java
there are a few ways of doing it. The 2 that
we need to know about are;
• IF statements
• Switch Case
The Selection Constructs
Imagine we are creating a form that allows
users to input their date of birth like this
one.


  What would our IF
  statement say if I wanted
  to output the NAME of
  the month and not the
  NUMBER of the month?
IF Statement
int month = 7;
if (month == 1) {
          37 lines of
System.out.println("January");
}

            code!
else if (month == 2) {
System.out.println("February");
}
... // and so on
Switch Case
int month = 8;
String monthString;
switch (month) {
case 1: monthString = "January"; break;
case 2: monthString = "February"; break;

              18 lines of
case 3: monthString = "March"; break;
case 4: monthString = "April"; break;
case 5: monthString = "May"; break;
case 6: monthString = "June"; break;


                code!
case 7: monthString = "July"; break;
case 8: monthString = "August"; break;
case 9: monthString = "September"; break;
case 10: monthString = "October"; break;
case 11: monthString = "November"; break;
case 12: monthString = "December"; break; default:
monthString = "Invalid month"; break;
}
System.out.println(monthString);
Your Task
Using the Forum on Topic 7, you will
need to write a Switch Case for a
program that will output a message
showing the year a student is in. For
example;

“You are in
Year 10!”
Exam Question
On Jogle you will see a 4 mark exam
question on Switch Cases. You will need
to complete this and try and get all 4
marks.

Mais conteúdo relacionado

Destaque

Volcanoes - presentation by Sam G.
Volcanoes - presentation by Sam G.Volcanoes - presentation by Sam G.
Volcanoes - presentation by Sam G.
Danuta W-Piwko
 
C:\documents and settings\sandy.hawkins\my documents\anne frank powerpoint
C:\documents and settings\sandy.hawkins\my documents\anne frank powerpointC:\documents and settings\sandy.hawkins\my documents\anne frank powerpoint
C:\documents and settings\sandy.hawkins\my documents\anne frank powerpoint
sandyhawkins58
 
L3 how do images work
L3   how do images workL3   how do images work
L3 how do images work
listergc
 
L3 more networking
L3   more networkingL3   more networking
L3 more networking
listergc
 
Planning Your Code
Planning Your CodePlanning Your Code
Planning Your Code
listergc
 
Anne frank vocab. 1
Anne frank vocab. 1Anne frank vocab. 1
Anne frank vocab. 1
Hank Maine
 
Term 1 - C&B Stars
Term 1 - C&B StarsTerm 1 - C&B Stars
Term 1 - C&B Stars
listergc
 
Graphical User Interface
Graphical User InterfaceGraphical User Interface
Graphical User Interface
listergc
 
Volcano presentation by Tan
Volcano presentation by TanVolcano presentation by Tan
Volcano presentation by Tan
Danuta W-Piwko
 

Destaque (20)

L2
L2L2
L2
 
Presentation Sophie
Presentation SophiePresentation Sophie
Presentation Sophie
 
Volcanoes - presentation by Sam G.
Volcanoes - presentation by Sam G.Volcanoes - presentation by Sam G.
Volcanoes - presentation by Sam G.
 
C:\documents and settings\sandy.hawkins\my documents\anne frank powerpoint
C:\documents and settings\sandy.hawkins\my documents\anne frank powerpointC:\documents and settings\sandy.hawkins\my documents\anne frank powerpoint
C:\documents and settings\sandy.hawkins\my documents\anne frank powerpoint
 
L8
L8L8
L8
 
L3 how do images work
L3   how do images workL3   how do images work
L3 how do images work
 
L3 more networking
L3   more networkingL3   more networking
L3 more networking
 
L4
L4L4
L4
 
Pp t3
Pp t3Pp t3
Pp t3
 
Planning Your Code
Planning Your CodePlanning Your Code
Planning Your Code
 
Anne frank vocab. 1
Anne frank vocab. 1Anne frank vocab. 1
Anne frank vocab. 1
 
L5
L5L5
L5
 
Term 1 - C&B Stars
Term 1 - C&B StarsTerm 1 - C&B Stars
Term 1 - C&B Stars
 
Fire of london_questions
Fire of london_questionsFire of london_questions
Fire of london_questions
 
L2
L2L2
L2
 
L1
L1L1
L1
 
Graphical User Interface
Graphical User InterfaceGraphical User Interface
Graphical User Interface
 
Volcano presentation by Tan
Volcano presentation by TanVolcano presentation by Tan
Volcano presentation by Tan
 
L1
L1L1
L1
 
L7
L7L7
L7
 

Semelhante a Switch Case

Walter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docx
Walter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docxWalter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docx
Walter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docx
melbruce90096
 
Intro to javascript (5:2)
Intro to javascript (5:2)Intro to javascript (5:2)
Intro to javascript (5:2)
Thinkful
 
Basics of Programming - A Review Guide
Basics of Programming - A Review GuideBasics of Programming - A Review Guide
Basics of Programming - A Review Guide
Benjamin Kissinger
 
Write a program to generate the entire calendar for one year. The pr.pdf
Write a program to generate the entire calendar for one year. The pr.pdfWrite a program to generate the entire calendar for one year. The pr.pdf
Write a program to generate the entire calendar for one year. The pr.pdf
arihantmobileselepun
 
Dot Net Accenture
Dot Net AccentureDot Net Accenture
Dot Net Accenture
Sri K
 

Semelhante a Switch Case (20)

Walter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docx
Walter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docxWalter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docx
Walter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docx
 
Switch statement
Switch statementSwitch statement
Switch statement
 
Vba and macro creation (using excel)
Vba and macro creation (using excel)Vba and macro creation (using excel)
Vba and macro creation (using excel)
 
C programming
C programmingC programming
C programming
 
unit_tests_tutorial
unit_tests_tutorialunit_tests_tutorial
unit_tests_tutorial
 
Cis 1403 lab1- the process of programming
Cis 1403 lab1- the process of programmingCis 1403 lab1- the process of programming
Cis 1403 lab1- the process of programming
 
Excel Excellence (Microsoft Excel training that "sticks"): Macros
Excel Excellence (Microsoft Excel training that "sticks"): MacrosExcel Excellence (Microsoft Excel training that "sticks"): Macros
Excel Excellence (Microsoft Excel training that "sticks"): Macros
 
Intro to javascript (5:2)
Intro to javascript (5:2)Intro to javascript (5:2)
Intro to javascript (5:2)
 
Ecs 10 programming assignment 4 loopapalooza
Ecs 10 programming assignment 4   loopapaloozaEcs 10 programming assignment 4   loopapalooza
Ecs 10 programming assignment 4 loopapalooza
 
AVB201.2 Microsoft Access VBA Module 2
AVB201.2 Microsoft Access VBA Module 2AVB201.2 Microsoft Access VBA Module 2
AVB201.2 Microsoft Access VBA Module 2
 
Basics of Programming - A Review Guide
Basics of Programming - A Review GuideBasics of Programming - A Review Guide
Basics of Programming - A Review Guide
 
Class7 term3 2019-2020
Class7 term3 2019-2020Class7 term3 2019-2020
Class7 term3 2019-2020
 
General Talk on Pointers
General Talk on PointersGeneral Talk on Pointers
General Talk on Pointers
 
Learn VBA Training & Advance Excel Courses in Delhi
Learn VBA Training & Advance Excel Courses in DelhiLearn VBA Training & Advance Excel Courses in Delhi
Learn VBA Training & Advance Excel Courses in Delhi
 
The Sieve of Eratosthenes - Part 1
The Sieve of Eratosthenes - Part 1The Sieve of Eratosthenes - Part 1
The Sieve of Eratosthenes - Part 1
 
Small Basic Calculator Apps lesson
Small Basic Calculator Apps lessonSmall Basic Calculator Apps lesson
Small Basic Calculator Apps lesson
 
Write a program to generate the entire calendar for one year. The pr.pdf
Write a program to generate the entire calendar for one year. The pr.pdfWrite a program to generate the entire calendar for one year. The pr.pdf
Write a program to generate the entire calendar for one year. The pr.pdf
 
The Sieve of Eratosthenes - Part 1 - with minor corrections
The Sieve of Eratosthenes - Part 1 - with minor correctionsThe Sieve of Eratosthenes - Part 1 - with minor corrections
The Sieve of Eratosthenes - Part 1 - with minor corrections
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
 
Dot Net Accenture
Dot Net AccentureDot Net Accenture
Dot Net Accenture
 

Mais de listergc

Validation, verification, output and backup
Validation, verification, output and backupValidation, verification, output and backup
Validation, verification, output and backup
listergc
 
L4 internet security
L4   internet securityL4   internet security
L4 internet security
listergc
 
L1 networking basics
L1   networking basicsL1   networking basics
L1 networking basics
listergc
 
L1 networking basics
L1   networking basicsL1   networking basics
L1 networking basics
listergc
 
L2 communication methods
L2   communication methodsL2   communication methods
L2 communication methods
listergc
 
Introduction to operating systems
Introduction to operating systemsIntroduction to operating systems
Introduction to operating systems
listergc
 
Y12 peripherals
Y12   peripherals Y12   peripherals
Y12 peripherals
listergc
 
Y12 peripherals
Y12   peripherals Y12   peripherals
Y12 peripherals
listergc
 
Describe primary and secondary memory inc
Describe primary and secondary memory incDescribe primary and secondary memory inc
Describe primary and secondary memory inc
listergc
 
Systems software and applications packages
Systems software and applications packagesSystems software and applications packages
Systems software and applications packages
listergc
 
Components of a computer system
Components of a computer systemComponents of a computer system
Components of a computer system
listergc
 
Key database terms
Key database termsKey database terms
Key database terms
listergc
 
Normalisation
NormalisationNormalisation
Normalisation
listergc
 
Normalisation
NormalisationNormalisation
Normalisation
listergc
 

Mais de listergc (20)

L2
L2L2
L2
 
Validation, verification, output and backup
Validation, verification, output and backupValidation, verification, output and backup
Validation, verification, output and backup
 
L4 internet security
L4   internet securityL4   internet security
L4 internet security
 
L1 networking basics
L1   networking basicsL1   networking basics
L1 networking basics
 
L1 networking basics
L1   networking basicsL1   networking basics
L1 networking basics
 
L2 communication methods
L2   communication methodsL2   communication methods
L2 communication methods
 
Introduction to operating systems
Introduction to operating systemsIntroduction to operating systems
Introduction to operating systems
 
L6
L6L6
L6
 
Y12 peripherals
Y12   peripherals Y12   peripherals
Y12 peripherals
 
Y12 peripherals
Y12   peripherals Y12   peripherals
Y12 peripherals
 
Describe primary and secondary memory inc
Describe primary and secondary memory incDescribe primary and secondary memory inc
Describe primary and secondary memory inc
 
L9
L9L9
L9
 
L7
L7L7
L7
 
L6
L6L6
L6
 
Systems software and applications packages
Systems software and applications packagesSystems software and applications packages
Systems software and applications packages
 
Components of a computer system
Components of a computer systemComponents of a computer system
Components of a computer system
 
Key database terms
Key database termsKey database terms
Key database terms
 
Normalisation
NormalisationNormalisation
Normalisation
 
Normalisation
NormalisationNormalisation
Normalisation
 
L1
L1L1
L1
 

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
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
 
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
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.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
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 

Switch Case

  • 1. Task 1 In the first of today’s lessons your will need to complete your GUI work and upload it. Once you have done this you will be working through the Greenfoot tutorials.
  • 2. Learning outcomes By the end of today’s lesson; • All of you will create basic Switch Cases • Most of you will ensure all the syntax is correct for your Switch Cases • Some of you will create a detailed Switch Case which includes Strings
  • 3. The Selection Constructs When we want to perform a check in Java there are a few ways of doing it. The 2 that we need to know about are; • IF statements • Switch Case
  • 4. The Selection Constructs Imagine we are creating a form that allows users to input their date of birth like this one. What would our IF statement say if I wanted to output the NAME of the month and not the NUMBER of the month?
  • 5. IF Statement int month = 7; if (month == 1) { 37 lines of System.out.println("January"); } code! else if (month == 2) { System.out.println("February"); } ... // and so on
  • 6. Switch Case int month = 8; String monthString; switch (month) { case 1: monthString = "January"; break; case 2: monthString = "February"; break; 18 lines of case 3: monthString = "March"; break; case 4: monthString = "April"; break; case 5: monthString = "May"; break; case 6: monthString = "June"; break; code! case 7: monthString = "July"; break; case 8: monthString = "August"; break; case 9: monthString = "September"; break; case 10: monthString = "October"; break; case 11: monthString = "November"; break; case 12: monthString = "December"; break; default: monthString = "Invalid month"; break; } System.out.println(monthString);
  • 7. Your Task Using the Forum on Topic 7, you will need to write a Switch Case for a program that will output a message showing the year a student is in. For example; “You are in Year 10!”
  • 8. Exam Question On Jogle you will see a 4 mark exam question on Switch Cases. You will need to complete this and try and get all 4 marks.