Computer Science 1 Warm-up: True/False Dry Run

Slides:



Advertisements
Similar presentations
1. ( ) ÷ 1 = (A) 1818 (B) 1414 (C) 4 15 (D) 1212 (E) ( ) ÷ 1 = ÷ 1 = = ( ) ÷ 1 =
Advertisements

Pascal Syntax. What you have learnt so far writeln() and write(); readln() and read(); variables (integers, strings, character) manipulation of variables.
Pascal Programming Today Chapter 4 1 »Conditional statements allow the execution of one of a number of possible operations. »Conditional statements include:
Selection Boolean What is Boolean ? Boolean is a set with only two values : –true –false true and false are standard identifiers in Pascal, called Boolean.
Programming, an introduction to Pascal
1 st semester Basic Pascal Elements อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Copyright © 2000, Department of Systems and Computer Engineering, Carleton University 1 If’s – The Basic Idea “Program” for hubby: take out garbage.
Algebraic thinking Math 123. Warm-up Solve the following equations: 2a - 13 = 15a 3b – 8 = 4b – 4c = 15.
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:
INTRODUCTION TO PROGRAMMING. Program Development Life Cycle The program development life cycle is a model that describes the stages involved in a program.
 1. The points whose coordinates are (3,1), (5,-1), and (7,-3) all lie on the same line. What could be the coordinates of another point on that line?
Java Review if Online Time For loop Quiz on Thursday.
Computer Science I: Understand how to evaluate expressions with DIV and MOD Random Numbers Reading random code Writing random code Odds/evens/…
15.1 More About High-Level Programming Languages Syntax and Semantics Each programming language contains its own rules for both syntax and semantics. Syntax.
CMSC201 Computer Science I for Majors Lecture 03 – Operators
Solving Linear Equations in One Variable
Objective The learner will solve problems using formulas
CMSC201 Computer Science I for Majors Lecture 03 – Operators
Program Options: 10 Minutes online
Review Dry Run A Little More Math Fix it Online time
Warm-Up #6 (Thursday, 9/17) Determine whether each statement is true or false. Use examples to support your claim. The product of two positive integers.
Conditional Statements
Program options Write a program for one of the following
Java Fix a program that has if Online time for Monday’s Program
Solving Linear Equations in One Variable
Computer Science 1 Online time to complete/enhance second repeat program Be able to read and write a program that uses the ‘case’ statement.
Computer Science II First With files.
Computer Science II First With files.
Java Variables, Types, and Math Getting Started
Truth tables: Ways to organize results of Boolean expressions.
How can you model playing rock-paper-scissors?
Review Dry Run Taking Names Online time Math is Good
kbkjlj/m/lkiubljj'pl;
Computer Science 1 Get out your notebook
Dry run Fix Random Numbers
More Maths Programming Guides.
Program Options: 10 Minutes online
Truth tables: Ways to organize results of Boolean expressions.
Java Fix a program that has if Online time for Monday’s Program
Summary Two basic concepts: variables and assignments Basic types:
Computer Science
Truth tables: Ways to organize results of Boolean expressions.
Computer Science 1 Online time for Graphics Program Random review
How can you make a guessing game?
Computer Science II Second With files.
Triangles 7.G.2 Focus on knowing the properties of triangles from three measures of angles or sides, noticing when the conditions determine a unique.
Computer Science Procedures Day 2.
Computer Science 2 More Trees.
Computer Science Procedures Day 2.
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
Warm-up: True/False Dry Run DIV / MOD 2nd If Then Program
Computer Science I: Get out your notes.
Section 1.5 Solving Equations.
How can you model playing rock-paper-scissors?
Program options Write a program for one of the following
Computer Science 1 while
Computer Science 1 while
Computer Science 1 Get out your notebook
Computer Science 1 Get out your notebook
Dry Run Fix it Write a program
Computer Science And he made a molten sea, ten cubits from the one brim to the other: it was round all about, and his height was five cubits: and.
A bit of Review Review, Dry Run, Program.
Write a Fraction as a Terminating Decimal
COMPUTING.
Computer Science II First With files.
Presentation transcript:

Computer Science 1 Warm-up: True/False Dry Run Online Time to Finish/push the If program DIV / MOD 2nd If Then Program

Take out your notes and number your paper from 1 to 11. Var A,b,c:integer; E,f,g:real; H, i:string; Begin A:= 5; b:=10;c:=2; E:=5.0;f:=3.0;g:=10.5; H:= ‘Howdy’;i:= ‘Doody’; 1) a<b 2) c>a 3) e>c 4) h<= i 5) (a<b) or (a<c) 6) (3*a >g) 7) (a<b) and (b<c) 8) NOT (a>10) 9) H > i 10) NOT (H = ‘howdy’) 11) H > A Take out your notes and number your paper from 1 to 11. George Boole True, False or crash

Dry run the following program dryruny; var one, two:integer; begin two:= one*2 - 1; writeln(one:6, two:6); if (one <= two) then writeln('Scooby') else writeln('Scrappy'); end.

Program options. Quiz this Thursday Input: A test score. Output: A congratulations if the score is above 90. Push: Add comments for scores 80-90, 70 – 80 , 60 – 70 etc… Input: The lengths for three sides of a triangle. Output: Whether or not the three sides make a triangle. Push: Calculate the area of this triangle. Push: Determine if it is a right triangle. Input: Three scores. Output the three scores in order lowest to highest.

Dry Run DIV..MOD If..then review Conditions Program Computer Science 1 Dry Run DIV..MOD If..then review Conditions Program

Dry Run the following program ifOne; var a,b:integer; begin a:= 10; if a>b then a:= a - 4; b:=b+1; end; writeln(a,b); readln; end.

DIV Pascal’s Integer Division How can you get an integer result when you divide? For example, if you divide 5 by 2 what do you think the answer would be? What about the remainder. Pascal has math operations for finding the result of integer division and the remainder of integer division.

DIV and MOD DIV is used to find the result of integer division For example X := 13 DIV 5; X:= 21 DIV 10; X:= 20 – 8 DIV 3; x:= 1 DIV 2; MOD is used to find the remainder of integer division X := 13 MOD 5; X:= 21 MOD 10; X:= 20 – 8 MOD 3; x:= 1 MOD 2;

DIV and MOD samples Ans:=23 DIV 10; Ans:= 14 DIV 4; Ans:= 52 DIV 5; Ans:= 23 MOD 10; Ans:= 14 MOD 4; Ans:= 52 MOD 5; Ans:= 14 MOD 3; Ans:= 8 MOD 9; Ans:= 5 MOD 10; Ans:= 4.13 MOD 2;

If..then and if..then..else When Semantics If it makes sense to say if, it probably makes sense to use if Semantics

Syntax: If..Then If (condition) then Begin {Commands to do when the condition is TRUE} end; Program IfThenSample; Var Testscore:integer; Begin Writeln(‘Please enter a test score’); Readln(testscore)’ If (testscore>95) then Writeln(‘Congratulations’); Writeln(‘Keep up the good work’); End; End.

Conditions: Boolean Always results in a TRUE or FALSE Go over <, >, <=, >=, =, <>, AND, OR, NOT Use () as needed Types must match* (Can compare real and integer)

Dry run the following program dryrun5; var one, two:integer; begin two:= one*2 - 1; writeln(one:6, two:6); if ((two MOD 2) = 0) then writeln('Scooby') else writeln('Scrappy'); if (one MOD 2 <>0) then writeln(‘Fred’) writeln(‘Wilma’); end.

Program options. Quiz Friday Input: The amount of change (Integer value, like 66 cents) Output: The least amount of coins it takes to make the change: For 66 cents 2 Quarter(s) 1 Dime(s) 1 Nickel(s) 1 Penny/Pennies Input: The number of Chirps per minute for a cricket. Output: The outside temperature in Fahrenheit and give an appropriate statement if the temperature is greater than 90 degrees F. Using his equation, called Dolbear's Law, you can determine the approximate temperature in Fahrenheit, based on the number of cricket chirps you hear in one minute. Dolbear's Law: T = 50+[(N-40)/4]  T = temperature  N = number of chirps per minute Push: Add other comments for different temperatures, The above equation is for field crickets, look up equations for different types of crickets.