Warm-up: True/False Dry Run DIV / MOD 2nd If Then Program Computer Science 1 Warm-up: True/False Dry Run 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.
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;
Program options. 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.