Console.WriteLine(“Good luck!”);

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

CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
While Loops. Challenge: ● Ask the user a simple math questions ● Continue asking the question until the user gets it right.
CS0004: Introduction to Programming Repetition – Do Loops.
Top-Down Design CSC 161: The Art of Programming Prof. Henry Kautz 9/16/2009.
Loops (Part 1) Computer Science Erwin High School Fall 2014.
Mock test review Revision of Activity Diagrams for Loops,
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 5, 2005.
COMP 14 Introduction to Programming Mr. Joshua Stough February 16, 2005 Monday/Wednesday 11:00-12:15 Peabody Hall 218.
Do Loop The syntax of DO loop: DO variable = initial_value, final_value[, increment] [statements] END DO Example: PROGRAM LINES ! Illustration of DO-loops.
Loops – While, Do, For Repetition Statements Introduction to Arrays
COMP 14 Introduction to Programming Miguel A. Otaduy May 20, 2004.
ACSE th Conference The Iconic Programmer Stephen Chen.
COMP 110 Introduction to Programming Mr. Joshua Stough September 24, 2007.
COMP 1001: Introduction to Computers for Arts and Social Sciences Programming in Scratch Monday, May 16, 2011.
While Loops CMSC 201. Overview Today we will learn about: Looping Structures While loops.
Chapter 6 - VB 2005 by Schneider1 Chapter 6 – Repetition 6.1 Do While and Do Until Loops 6.2 Processing Lists of Data with Do Loops 6.3 For...Next Loops.
Sequences Jordi Cortadella Department of Computer Science.
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
Statements That Repeat. For...Next Loop Structure For counter = start To end Step increment statements Next counter Where Counter is tested to see if.
Coding Design Tools Rachel Gauci. What are Coding Design Tools? IPO charts (Input Process Output) Input- Make a list of what data is required (this generally.
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
Chapter 4: Control Structures II
Bubble Sort.
Logical Operators, Boolean Variables, Random Numbers This template was just too good to let go in one day!
Chapter 7 Problem Solving with Loops
Iteration & Loop Statements 1 Iteration or Loop Statements Dept. of Computer Engineering Faculty of Engineering, Kasetsart University Bangkok, Thailand.
Tutorial 9 Iteration. Reminder Assignment 8 is due Wednesday.
LECTURE # 8 : REPETITION STATEMENTS By Mr. Ali Edan.
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
While loops. Iteration We’ve seen many places where repetition is necessary in a problem. We’ve been using the for loop for that purpose For loops are.
General Condition Loop A general condition loop just loops while some condition remains true. Note that the body of the loop should (eventually) change.
Loops ( while and for ) CSE 1310 – Introduction to Computers and Programming Alexandra Stefan 1.
7 - Programming 7J, K, L, M, N, O – Handling Data.
Growth of Functions & Algorithms
CSC111 Quick Revision.
Applied Discrete Mathematics Week 2: Functions and Sequences
REPETITION CONTROL STRUCTURE
Data Structures and Algorithms
Java for Beginners.
CS1371 Introduction to Computing for Engineers
Week 4 – Repetition Structures / Loops
Diamond Hunt Mock Programming Project.
Chapter 4 – Control Structures Part 1
While Loops in Python.
Siti Nurbaya Ismail Senior Lecturer
Reindeer don't go to public school, they’re elf taught.
Writing Functions( ) (Part 5)
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.
Arrays, For loop While loop Do while loop
Control Structure Senior Lecturer
Linear and Binary Search
Java for Beginners University Greenwich Computing At School DASCO
Introduction to Python
Lecture Notes – Week 3 Lecture-2
<INSERT_WITTY_QUOTE_HERE>
Java Programming Loops
Console.WriteLine(“Good luck!”);
Module 4 Loops.
Lec 4: while loop and do-while loop
Do … Loop Until (condition is true)
Computer Science Core Concepts
What's wrong with Easter jokes? They crack you up
OBJECT ORIENTED PROGRAMMING I LECTURE 11 GEORGE KOUTSOGIANNAKIS
Functions continued.
Java Programming Loops
Arrays.
Programming Dr. Jalal Kawash.
Algorithms.
Presentation transcript:

Console.WriteLine(“Good luck!”); PC01 Term 2 Test Console.WriteLine(“Good luck!”);

This term we have covered: Introduction This term we have covered: While loops Do-while loops For loops Bubble sort Linear search It’s time to test your knowledge!

Create a random number generator Test Exercise 1 Make a new project Create a random number generator Declare an integer variable called “maximum” and give it a random value between 10 and 20 Using a for loop, output all numbers from maximum down to zero (inclusive) For example, if maximum = 10, your output should be “10 9 8 7 6 5 4 3 2 1 0”

Test Exercise 2 Create a for loop that goes over all numbers between 0 and 10 and uses a variable called i as a counter Inside, create another for loop that also goes over numbers between 0 and 10 and uses j as a counter Using Console.Write, output a tab (use the “\t” escape sequence) followed by i*j Then, after the inner for loop (but still inside the outer loop) use Console.WriteLine to move on the next line

Your output should look like this: Test Exercise 2 Your output should look like this:

Declare an boolean variable and call it repeat and set it to false Test Exercise 3 Declare an boolean variable and call it repeat and set it to false Declare an array of strings and call it names Fill it with at least five different names Declare a do while loop It should print a random name from names array

If they type “yes” then set repeat to true Test Exercise 3 Still inside the loop, ask the user if they want to see another name and then get their input and save in a string variable If they type “yes” then set repeat to true If they type anything else set it to false Repeat the loop if repeat is equal to true

Move on to the next slide for some extra exercises END OF TEST Move on to the next slide for some extra exercises

Using an if statement, compare every element in names with longestName Test Exercise 4 Declare a string variable called “longestName” and set it to an empty string Create a for loop that starts at 0 and ends at names.Length (or names.GetLength(0)) Using an if statement, compare every element in names with longestName If the current element’s length is greater than longestName’s length, set longestName to the current name

This flowchart might help you: Test Exercise 4 This flowchart might help you:

Extension (not marked) If you’re done, create a rock-paper-scissors game (player vs ai) Use a while loop to keep the game running until someone wins at least three times