Welcome back! October 11, 2018.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Week 2: Primitive Data Types 1.  Programming in Java  Everything goes inside a class  The main() method is the starting point for executing instructions.
10-Jun-15 Just Enough Java. Variables A variable is a “box” that holds data Every variable has a name Examples: name, age, address, isMarried Variables.
5-1 Flow of Control Recitation-01/25/2008  CS 180  Department of Computer Science  Purdue University.
16-Jun-15 Additional control structures. 2 The if-else statement The if-else statement chooses which of two statements to execute The if-else statement.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Primitive Types Java supports two kinds of types of values – objects, and – values of primitive data types variables store – either references to objects.
CS 106 Introduction to Computer Science I 09 / 28 / 2007 Instructor: Michael Eckmann.
Chapter 5 Loops Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved.
Flow of Control Part 1: Selection
New Tools And Workshop Mod & For Loops. Modulo Calculates the remainder (remember long division?) % Examples: 7 % 3 10 % 2 2 % 3 evaluates to 1 evaluates.
1 BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA AND DEFINITE LOOPS.
1-Dec-15 Additional control structures. 2 The if-else statement The if-else statement chooses which of two statements to execute The if-else statement.
Lecture 10. Review (Char) Character is one of primitive data types of variable (such as integer and double) –Character variable contains one character.
CPSC 233 Tutorial 5 February 2 th /3 th, Java Loop Statements A portion of a program that repeats a statement or a group of statements is called.
Copyright © 2014 by John Wiley & Sons. All rights reserved.1 Decisions and Iterations.
CS 115 OBJECT ORIENTED PROGRAMMING I LECTURE 11 GEORGE KOUTSOGIANNAKIS 1 Copyright: 2015 Illinois Institute of Technology_ George Koutsogiannakis.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
John Hurley Spring 2011 Cal State LA CS 201 Lecture 5:
Comp1004: Loops and Arrays I Whiles, For and Arrays[]
UCT Department of Computer Science Computer Science 1015F Iteration
if ( condition ) statement; if is a Java reserved word The condition must be a boolean expression. It must evaluate to either true or false.
Repetition Statements
Slides by Evan Gallagher
Discussion 4 eecs 183 Hannah Westra.
CSC 211 Java I for loops and arrays.
Week 2 - Wednesday CS 121.
Whatcha doin'? Aims: To start using Python. To understand loops.
Chapter 2 Basic Computation
Chapter 4 Repetition Statements (loops)
The switch Statement, and Introduction to Looping
CS161 Introduction to Computer Science
Java for Beginners University Greenwich Computing At School DASCO
Chapter 6 More Conditionals and Loops
Multiple variables can be created in one declaration
The order in which statements are executed is called the flow of control. Most of the time, a running program starts at the first programming statement,
Iterations Programming Condition Controlled Loops (WHILE Loop)
Loops CS140: Introduction to Computing 1 Savitch Chapter 4 Flow of Control: Loops 9/18/13 9/23/13.
While loops The while loop executes the statement over and over as long as the boolean expression is true. The expression is evaluated first, so the statement.
Lesson 2: Building Blocks of Programming
Conditional Statements
Outline Altering flow of control Boolean expressions
Selection (if-then-else)
Introduction to Object-Oriented Programming with Java--Wu
© A+ Computer Science - What is a LOOP? © A+ Computer Science -
Announcements Exam 1 Thursday 50 minutes 10 % of Total Grade
Announcements Exam 1 Thursday Everything through Lab 5 50 minutes
Chapter 5 Loops Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved.
Control Structure Chapter 3.
OBJECT ORIENTED PROGRAMMING I LECTURE 11 GEORGE KOUTSOGIANNAKIS
A LESSON IN LOOPING What is a loop?
Building Java Programs
If-statements & Indefinite Loops
Building Java Programs
Midterm Review October 23, 2006 ComS 207: Programming I (in Java)
Introduction to Computer Science
CSC 1051 – Data Structures and Algorithms I
Unit 3: Variables in Java
Additional control structures
Just Enough Java 17-May-19.
Building Java Programs
‘do’ and ‘for’ loops October 1, 2007 ComS 207: Programming I (in Java)
Loops and Iteration CS 21a: Introduction to Computing I
Control Structure.
‘do’ and ‘for’ loops October 2, 2006 ComS 207: Programming I (in Java)
Looping Structures.
Repetition CSC 1051 – Data Structures and Algorithms I Course website:
Computer Science Club 1st November 2019.
Presentation transcript:

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!