condition & loop android club 2015. agenda if/else switch loops

23
Condition & loop Android Club 2015

Upload: phoebe-mcdowell

Post on 18-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Condition & loop

Android Club 2015

Page 2: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Agenda

if/else• Switch• Loops

Page 3: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Condition: if

int month = 3;if (month == 3) {

System.out.println("March");}

Page 4: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Condition: if - practice

• Check if month August

Page 5: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Condition: else if

int month = 8;if (month == 4) {

System.out.println("March");} else if(month==8){

System.out.println("August");}

Page 6: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Condition: else if - practice

• Make conditional statement for all month – January - December

Page 7: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Condition: else

else {System.out.println("There is

not such month");}

Page 8: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Switch

int month= 3;

switch (month) {case 1:

System.out.println(“January");break;

case 2:System.out.println(“February");break;

default:System.out.println("This is no such month");

}

Page 9: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Switch: practice

• Create switch which shows day of week by its number

Page 10: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Switch: practice 2

• 400 – Bad Request• 401 – Unauthorized• 403 – Forbidden• 404 – Not found• 500 - Internal Server Error• Using switch show this errors

Page 11: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Loop: for

for (int i = 10; i < 20; i++) {System.out.println(i);

}

Page 12: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Loop: for - practice

• Print numbers from 100 till 900, inclusive

Page 13: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Loop: for – practice 2

• Find sum of numbers from 1 till 1000 inclusive

Page 14: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Loop: for – practice 3

• Using your month switch print all month

Page 15: Condition & loop Android Club 2015. Agenda if/else Switch Loops

while

int x=0;while(x<10){

System.out.println(x);x++;

}

Page 16: Condition & loop Android Club 2015. Agenda if/else Switch Loops

While - practice

• Print numbers from 1 till 1 000 000

Page 17: Condition & loop Android Club 2015. Agenda if/else Switch Loops

While – practice 2

• Find sum of numbers from 1 to 333 inclusive

Page 18: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Let’s practice

•http://codingbat.com/

Page 19: Condition & loop Android Club 2015. Agenda if/else Switch Loops

More practice!

• What can be better than practice? – More practice

•https://projecteuler.net

Page 20: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Questions?

• Any questions?

Page 21: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Review

• Lynda.com - Java Essential Training - 5. Exploring Syntax and Flow

Page 22: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Homework

• http://codingbat.com/java/Logic-1• Project Euler – 5 tasks

Page 23: Condition & loop Android Club 2015. Agenda if/else Switch Loops

Thank you

• Thank you for your attention!