Presentation is loading. Please wait.

Presentation is loading. Please wait.

Program Options: 10 Minutes online

Similar presentations


Presentation on theme: "Program Options: 10 Minutes online"— 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 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 How do you start, when you don’t know where to start?
Computer Science 1 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:= ; 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; end. Dry run 1 (What do you think the following program does?) a b c Screen

6

7 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);

8 You turn: What is the result of the following?
Expression Answer Type 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:= ; Y:= 10; Writeln(y); Writeln(‘Hello’, y); Writeln(‘World’, x:10:2); readln; End.

11 Translate to Pascal Math Java 2(a+c) Ans=2*(a+c); 3x + 5y (1/2)bh πr2

12 Learning Objectives Be able to fix a poorly written program
Review math in Pascal Determine how to start a program when you don’t know how to start Write programs that solve math problems

13 Fix it! Open this program from the class website.
Save it into your CompurScience folder. Fix it Turn it in as yourNameFix9-15

14 What Math Operations do you recall?
+ - * / () Sqrt() Sqr() Abs()

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

16 Sample program Input: The radius and height of a cylinder. Process:
Surface area = 2πr2+2 πrh Volume = πr2h Output: The Volume and surface area of the cylinder.

17 Hands on Test: Radius of 1 inch and height of 1 inch
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

18 Pseudo Code Describe what we did to solve this.

19 Dry Run Test the pseudo code

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

21 Program options Write a program for one of the following
Volume and surface area of cylinder (YourNameCylinder) 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. Write a program to calculate the volume of a spherical cap. Include the needed inputs. (YourNameSphere) a = radius of the cap r = radius of the sphere h = height of the cap

22 Write a second program for one of the following


Download ppt "Program Options: 10 Minutes online"

Similar presentations


Ads by Google