Welcome back! October 11, 2018
https://goo.gl/qusxHV Attendance! https://goo.gl/qusxHV
Upcoming Opportunities Mercer Island High School Coding Competition - 10/20 Please let us know if there are any events you think we should mention at the next meeting!
Review! Last week we learned about data types and print statements Let’s refresh our knowledge on the topics covered last week: https://play.kahoot.it/#/k/26f49424-1f67-46fe-a6c9- 4d8a0ac7a28d
Java Basics - Data Types String: sequence of characters like “Hello world!” int: primitive data type with a binary value represented by an integer like 7 or 54 double: holds point values like 3.5 or 23.5 long: holds a 64-bit integer short: holds 16-bit integer boolean: holds either a true or false value
Java Basics - Print Statements In Java, to print a line of code you need to use: System.out.println(); If you want to print without moving to the next line, use: System.out.print();
Review Practice Problem Print a statement that states your name, age, and favorite animal If you get that, try to put it into a method and then print
Onto new material!!! Now that we have reviewed what we learned last week, and done a practice problem, let's move on to for loops and conditional statements!
Loops: For Loops For Loops are useful for many things: Statement that specifies iteration Allows code to be executed repeatedly You can choose how many times you want the code to be repeated
for(int i = 0; i <10; i++) { } For Loops - Syntax for(int i = 0; i <10; i++) { } Note: i++ doesn’t always have to be ++, it can be +=2 (which increments by 2 instead) or += any number to increment by that number Go through the different parts of a for loop
For Loops - Example for(int i = 0; i <10; i++) { System.out.println(“I love computer science!”); } //this will print the statement “I love computer science!” ten times, each on a separate line
Loops - Different Types of Loops While loops While something is true (i.e. x > 5) then the computer will continuously complete a task int x = 7 while(x > 5){ System.out.println(“I love to code!”); } https://codingbat.com/doc/loop.html
Conditionals
If Statements - Example Int x = 5; if(x>3) { System.out.println(“YAY”); } The stuff highlighted is a conditional!
Practice Problems Loops: Given the set of strings “apple”, “orange”, “banana”, use a loop to print all of the strings Extra challenge: can you print this backwards? Taking the set of strings “5”, “6”, “7”, “8”, “9”, print every other number Try printing this backwards as well
Practice Problems Conditionals: Check if any random number is even with a conditional (Hint: %) Print a string if it has exactly 5 letters Write a program that accepts an age from the user and reports if they are eligible to vote (the age to vote is 18) Ask the user for two integers and print the greatest one among the two
More Advanced Problems Write a program to check whether a entered character is lowercase ( a to z ) or uppercase ( A to Z ) Create any random set of numbers and test all the numbers to see if they’re equal (many ways to do this!)
Thank You! Next Meeting: 10/18! We hope to see you there!