program options: 10 minutes online write a program that will display your home address as it would...

19
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.

Upload: megan-carr

Post on 18-Jan-2018

218 views

Category:

Documents


0 download

DESCRIPTION

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

TRANSCRIPT

Page 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,

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.

Page 2: 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,

Computer Science 19/15/2015

ReviewDry Run

Math in PascalHow do you start, when you don’t know

where to start?

Page 3: 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,

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

Page 4: 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,

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.

Page 5: 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,

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

Page 6: 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,
Page 7: 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,

Math Math Pascal Code Example+ + Ans:= first+second;- - Ans:= second – first;x * Ans := first * second;÷ / Ans := first / second() () Ans := (first + 2)/second;π PI Ans := PI;

52 sqr Ans := sqr(first);√ Sqrt() Ans:= sqrt(first);

Page 8: 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,

You turn: What is the result of the following?

Expression Answer Type2+ 125*(8-15)5 + 6*36 + 4/2 – 8(6+4)/2 – 8(6+4)/(2-8)Sqrt(9)Sqrt(4*4 + 9)Sqrt(sqr(3) + sqr(4))

Page 9: 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,

Summary

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

Page 10: 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,

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.

Page 11: 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,

Evaluate the following• 2*5-6• Sqr(8-2*2)• Sqrt(8-2*2)Translate to PascalX-2y(1/2)(bh)

Page 12: 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,

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.

Page 13: 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,

Sample program

• Input: The radius and height of a cylinder.• Process:

– Surface area = πr2 + πr2 +2 πrh– Volume = πr2h

• Output: The Volume and surface area of the cylinder.

Page 14: 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,

Hands on

– Surface area = πr2 + πr2 +2 πrh– Volume = πr2h

• Test: • Radius of 1 inch and height of 1 inch• Radius of 2 inches and height of 10 inches

Page 15: 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,

Pseudo Code

• Describe what we did to solve this.

Page 16: 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,

Dry Run

• Test the pseudo code

Page 17: 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,

Code

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

Page 18: 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,

Program optionso Write a program for one of the followingo Volume and surface area of cylinder

o Input: The radius and height of a cylinder.o Process:

o Surface area = πr2 + πr2 +2 πrho Volume = πr2h

o Output: The Volume and surface area of the cylinder.o Write a program to calculate the volume of a spherical

cap. Include the needed inputs.o a = radius of the capo r = radius of the sphereo h = height of the cap

Page 19: 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,

Write a second program for one of the following

aacbbroot

241

2