Computer Science 1 Online time to complete/enhance second repeat program Be able to read and write a program that uses the ‘case’ statement.

Slides:



Advertisements
Similar presentations
E.g.9 For to do loop for i:=1 to 10 do writeln(i); While do loop i:=1;
Advertisements

Looping while … do …. Condition Process 2 Process 1 Y Repeated Loop.
ABNIAC The following slide presentation is to acquaint the student with ABNIAC. The version used for presentation is the Java version, which can be found.
True or false A variable of type char can hold the value 301. ( F )
1 10/20/08CS150 Introduction to Computer Science 1 do/while and Nested Loops Section 5.5 & 5.11.
James Tam Loops In Pascal In this section of notes you will learn how to rerun parts of your program without having to duplicate your code.
Repetition Statements Repeating an Action A specified number of times While a Condition is True Until a Condition is True.
Flow of Control Part 1: Selection
Previously Repetition Structures While, Do-While, For.
Variables. Todays Lesson  In todays lesson you are going to:  Learn to use variables  Learn to ask for user input  Learn to save the users response.
1. Understand the application of Pseudo Code for programming purposes 2. Be able to write algorithms in Pseudo Code.
Intro to Nested Looping Intro to Computer Science CS1510 Dr. Sarah Diesburg.
End of unit assessment Challenge 1 & 2. Course summary So far in this course you have learnt about and used: Syntax Output to screen (PRINT) Variables.
Truth and while Today 15 Minutes online time to finish the random/Swing programs. Truth tables: Ways to organize results of Boolean expressions. Note Taking:
Java Review if Online Time For loop Quiz on Thursday.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 11.
Computer Science I: Understand how to evaluate expressions with DIV and MOD Random Numbers Reading random code Writing random code Odds/evens/…
AP Java Java’s version of Repeat until.
UCT Department of Computer Science Computer Science 1015F Iteration
15.1 More About High-Level Programming Languages Syntax and Semantics Each programming language contains its own rules for both syntax and semantics. Syntax.
GCSE COMPUTER SCIENCE Practical Programming using Python
Loops In Pascal In this section of notes you will learn how to rerun parts of your program without having to duplicate the code. Repetition in Pascal:
Writing Functions( ) (Part 5)
Program options Write a program for one of the following
Java Fix a program that has if Online time for Monday’s Program
Warm up Find the inverse of the function
Module 5 Lesson 3 Extreme Scratch Cards
Introduction to pseudocode
Basketball Drill Programming Alternatives
Pick a number, any number …
More Loops.
Intro to Nested Looping
Truth tables: Ways to organize results of Boolean expressions.
How can you model playing rock-paper-scissors?
Computer Science 1 Get out your notebook
Computer Science 2 Review the Bubble Sort
Introduction to TouchDevelop
Computer Science 2 Getting an unknown # of …. Into an array.
Dry run Fix Random Numbers
Truth tables: Ways to organize results of Boolean expressions.
Java Fix a program that has if Online time for Monday’s Program
Three Special Structures – Case, Do While, and Do Until
Repeat Day2 Dry Run Second Repeat Program
Intro to Nested Looping
Find the reference angle for the angle measuring {image}
Computer Science 1 Warm-up: True/False Dry Run
Computer Science Sorting Pre-Test Discussion/program
The first number is posted telling what random number was selected, I did this for testing purposes, in the real thing it would not be there. Since the.
Truth tables: Ways to organize results of Boolean expressions.
Computer Science 1 Online time for Graphics Program Random review
How can you model playing rock-paper-scissors?
How can you make a guessing game?
Sorting Develop a sorting algorithm
Computer Science 2 More Trees.
Computer Science 1 while
Computer Science 1 For..do loop Dry Run Take notes on the For loop
Warm-up: Dry Run DIV / MOD 2nd If Then Program
How can you make a guessing game?
Computer Science I: Get out your notes.
How can you model playing rock-paper-scissors?
Program options Write a program for one of the following
Computer Science 1 while
10/27/2016 Dry Run 2 Case Programs Fix it Second Case Program
Random Numbers while loop
Computer Science 1 while
Types of loops definite loop: A loop that executes a known number of times. Examples: Repeat these statements 10 times. Repeat these statements k times.
Computer Science 1 Get out your notebook
Computer Science 1 Get out your notebook
Dry Run Fix it Write a program
A bit of Review Review, Dry Run, Program.
Presentation transcript:

Computer Science 1 Online time to complete/enhance second repeat program Be able to read and write a program that uses the ‘case’ statement

Second Repeat Program Math tutor Boom! Write a program that will randomly generate an addition problem and let the user calculate and guess the correct answer until they get it correct. At the end it will show how many guesses it took to get the problem correct. Push: Add levels of difficulty Push: Include subtraction and multiplication problems. Push: Let the user pick how many problems they would like to have you ask. Boom! Write a program that has two graphic images moving randomly around the screen until they run into each other. Then show an explosion. Push: Be able to drive one of the images and have the other image chase it at half speed. (Will need to incorporate the commands keypressed, and readkey) Push: Be able to control both of the images.

How can you model playing rock-paper-scissors? Computer Science 1 How can you model playing rock-paper-scissors?

How do you model playing Rock-paper-scissors? What options do you have? How can you model each of these options?

Case statement When When you have 3 or more choices Semantics

Expression must be ordinal (integer or char) Case Syntax case expression of 5 : WriteLn('Int is 5'); 7..12,15 : WriteLn('Between 7..12 or 15'); else begin WriteLn('Undefined.'); writeln(‘Try again later’); end; {Of this choice} end;{Of the case.} Constants: if the expression resulted in a char, you would need to have character constants (Like ‘A’, ‘B’, …) Note case has no begin, but does have an end!!!

program CaseExample; var Choice:integer; begin writeln(‘Choose one of the following’); writeln(‘ 1 - Titan Burger’); writeln(‘ 2 - SwordFish Sandwich’); writeln(‘ 3 - Chicken Nuggets’); readln(choice); case choice of 1:begin writeln(‘Titan Burger $3.00’); writeln(‘Yum Yum’); end; 2: writeln(‘Swordfish $5.00’); 3: begin writeln(‘No Chicken’); writeln(‘We’’re very sorry’); end; {Of the case statement} end.

Dry run the following program casecheck; var counter:integer; begin for counter:= 1 to 9 do case counter MOD 5 of 0:write('often '); 1:write('What '); 2,4:write('is '); 3:write('not '); end; {Of the case} end; {Of the for loop} writeln; end.

Program options Planet weight Quadrant check Write a program that lets the user find their weight on any of the following planets/stars. Sun(27.94) Moon (0.17) Saturn (1.15) Mercury (0.37) Venus(0.88) Jupiter (2.64) Rock-paper-scissors against the computer (This one is tricky!) Quadrant check Input: The measure of an angle in degrees. Output: Which quadrant the angle falls into. 0<First Quadrant<90 90<Second <180 180<Third<270 270<Fourth<360 The series of quadrants starts all over again at 360. How do you handle when the angle matches an axis?