How can you model playing rock-paper-scissors?

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

Lecture 4: Javascript Basics Javascript is a scripting language based on pieces of C, C++, shell scripts, Pascal, Java, etc. Scripts – loosely typed C++
Looping while … do …. Condition Process 2 Process 1 Y Repeated Loop.
OUR SOLAR SYSTEM BY KALID NASR.
While Loops Programming. COMP102 Prog Fundamentals I: while Loops/Slide 2 Shortcut Assignments l C++ has a set of shortcut operators for applying an operation.
COMP 14 Introduction to Programming Miguel A. Otaduy May 19, 2004.
1 10/20/08CS150 Introduction to Computer Science 1 do/while and Nested Loops Section 5.5 & 5.11.
1 10/9/06CS150 Introduction to Computer Science 1 for Loops.
1 Loops When you want a computer to perform the same operation many times you use a loop. Looping is one of the keys to computer programming. First we.
The Solar System 4 th Grade Science Science Standards S4E2. Students will model the position and motion of the earth in the solar system and will explain.
The Solar System. Mercury Mercury is the closest planet to the sun. Mercury is the closest planet to the sun. Mercury is the eighth largest planet. Mercury.
Previously Repetition Structures While, Do-While, For.
Planets By Meagan Caine.
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.
A moon is a natural satellite of each planet. The moon only comes out at night and bights up the night sky.
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/…
Computer Science 101 For Statement. For-Statement The For-Statement is a loop statement that is especially convenient for loops that are to be executed.
Earth and spaces. Earth and spaces words cards Earth sun Moon Planets Star Solar system Mercury Venus Mars Jupiter Saturn.
It takes 88 days for Mercury to orbit the Sun. This is 0.2 years less days to orbit the Sun than Earth.
The Solar System. Mercury Mercury is the closest planet to the sun. Mercury is the closest planet to the sun.
15.1 More About High-Level Programming Languages Syntax and Semantics Each programming language contains its own rules for both syntax and semantics. Syntax.
The Solar System by Sadie Hudson Comments and Future Considerations:
Solar system.
For Free Science Videos for Kids
Gravity.
The Solar System.
INTERACTIVE OUTER SPACE GAME
Space 27th April 2017.
The Solar System A Fifth Grade Science.
a star a moon r dwarf planet a sun
Chapter 4: Making Decisions.
__ ______ __ ___ ____ _____
Writing Functions( ) (Part 5)
Conditional Statements
Introduction to pseudocode
CS1100 Computational Engineering
Computer Science 1 Online time to complete/enhance second repeat program Be able to read and write a program that uses the ‘case’ statement.
Intro to Nested Looping
How can you model playing rock-paper-scissors?
Dry run Fix Random Numbers
A Fifth Grade Science Presentation By Mrs. Lisa Brinks
Chapter 11 Looking at the Universe
Intro to Nested Looping
Computer Science 1 Warm-up: True/False Dry Run
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.
And we’re off to have fun! We’ll visit the planets,
Computer Science 1 while
Computer Science 1 For..do loop Dry Run Take notes on the For loop
Decisions, decisions, decisions

The Solar System Lauren Buchanan.
How can you make a guessing game?
OUR SOLAR SYSTEM OUR SOLAR SYSTEM HAS LOTS AND LOTS OF GALAXY INCLUDING OURS. - THE SOLAR SYSTEM FORMED ABOUT 4.6 BILLION YEARS AGO.
Computer Science
Computer Science I: Get out your notes.
The Planets of our Solar System The Terrestrial Planets
How can you model playing rock-paper-scissors?
The Solar System.
Computer Science 1 while
The Solar System.
10/27/2016 Dry Run 2 Case Programs Fix it Second Case Program
Computer Science 1 while
Dry Run Fix it Write a program
The knowledge determiner
Space By Emma and Clare.
A bit of Review Review, Dry Run, Program.
For Free Science Videos for Kids
Presentation transcript:

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. Input: Their weight, and which planet. Output: Their weight on the selected planet 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?