Presentation is loading. Please wait.

Presentation is loading. Please wait.

Program Options: 10 Minutes online Write a program that will display your home address as it would on an envelope. –First Name Last Name –Address –City,

Similar presentations


Presentation on theme: "Program Options: 10 Minutes online Write a program that will display your home address as it would on an envelope. –First Name Last Name –Address –City,"— Presentation transcript:

1 Program Options: 10 Minutes online Write a program that will display your home address as it would on an envelope. –First Name Last Name –Address –City, State Zip Code –Push: Let the user enter some or all of the information, and have your program format it. Write a mad-lib program –Have the user enter at least 4 pieces of information. Noun, Adverb (honestly), Adjective (messy), Verb, Geographical location, … –The computer will generate the mad-lib –Here is a sample website http://us.penguingroup.com/static/packages/us/yreaders/madlibs/fun.html Write a program that shows a poem or song. Can be an original work. Include space as appropriate. –Push: Look up for..do, or repeat..until to have your program repeat the song several times. –Push: Use the Pascal tutorial to add color etc.

2 Computer Science 1 9/15/2015 Review Dry Run Math in Pascal How do you start, when you don’t know where to start?

3 Goals Improve in your ability to execute a dry run. See how to let Pascal do the math. Go through pseudo code for the second programming assignment Give second programming assignment

4 Review: What do you recall about…? Program review; Var –X:real; –Y:integer; begin –Writeln(‘Hello world.’); –x:= 5.4321; –Y:= 10; –Writeln(y); –Writeln(‘Hello’, y); –Writeln(‘World’, x:10:2); –readln; End.

5 Dry run 1 (What do you think the following program does?) {Mr. Smith's Sample Program} {Dry Run #1} {9/15/2015} program DryRunTest; uses crt; var a,b,c:integer ; begin clrscr; a:= 8; b:= 6; c:= a+b; writeln(a, b, c); b:= b + 2*a; a:= a + 7; writeln(a, b, c); end. a b c Screen

6

7 Math PascalCode Example ++Ans:= first+second; --Ans:= second – first; x*Ans := first * second; ÷/Ans := first / second () Ans := (first + 2)/second; πPIAns := PI; 5252 sqrAns := sqr(first); √Sqrt()Ans:= sqrt(first);

8 You turn: What is the result of the following? ExpressionAnswerType 2+ 12 5*(8-15) 5 + 6*3 6 + 4/2 – 8 (6+4)/2 – 8 (6+4)/(2-8) Sqrt(9) Sqrt(4*4 + 9) Sqrt(sqr(3) + sqr(4))

9 Summary Write a one to three sentence summary of using Math in Pascal.

10 Review: What do you recall about…? Program review; Var –X:real; –Y:integer; begin –Writeln(‘Hello world.’); –x:= 5.4321; –Y:= 10; –Writeln(y); –Writeln(‘Hello’, y); –Writeln(‘World’, x:10:2); –readln; End.

11 Evaluate the following 2*5-6 Sqr(8-2*2) Sqrt(8-2*2) Translate to Pascal X-2y (1/2)(bh)

12 Steps to code Hands on –Doing samples by hand. Pseudo code –Write out instructions in English Dry Run –Testing your instructions Code –Translate the Pseudo-Code to Pascal.

13 Sample program Input: The radius and height of a cylinder. Process: –Surface area = πr 2 + πr 2 +2 πrh –Volume = πr 2 h Output: The Volume and surface area of the cylinder.

14 Hands on –Surface area = πr 2 + πr 2 +2 πrh –Volume = πr 2 h Test: Radius of 1 inch and height of 1 inch Radius of 2 inches and height of 10 inches

15 Pseudo Code Describe what we did to solve this.

16 Dry Run Test the pseudo code

17 Code Translate the Pseudo code to code, Pascal in the case of this class.

18 Program options oWrite a program for one of the following oVolume and surface area of cylinder oInput: The radius and height of a cylinder. oProcess: oSurface area = πr 2 + πr 2 +2 πrh oVolume = πr 2 h oOutput: The Volume and surface area of the cylinder. oWrite a program to calculate the volume of a spherical cap. Include the needed inputs. oa = radius of the cap or = radius of the sphere oh = height of the cap

19 Write a second program for one of the following


Download ppt "Program Options: 10 Minutes online Write a program that will display your home address as it would on an envelope. –First Name Last Name –Address –City,"

Similar presentations


Ads by Google