Presentation is loading. Please wait.

Presentation is loading. Please wait.

10/27/2016 Dry Run 2 Case Programs Fix it Second Case Program

Similar presentations


Presentation on theme: "10/27/2016 Dry Run 2 Case Programs Fix it Second Case Program"— Presentation transcript:

1 10/27/2016 Dry Run 2 Case Programs Fix it Second Case Program
Computer Science 1 10/27/2016 Dry Run 2 Case Programs Fix it Second Case Program

2 Learning Objectives Refine your knowledge of using the case statement by successfully completing a dry run Improve on your program correction abilities by correcting a program Complete your second case program.

3 program Kase; var x, y, z:integer; begin y:= 6; z:= 2; for x:= 1 to 6 do case x mod 4 of 1, 3: y:= y + 3; 2: z:= z*2; 0: z:= z + x; end; writeln(x:6, y:6, z:6); end. Dry Run the following.

4 Case dry run #2 program Kase2; var w, x, y, z:integer; begin x:= 3;
for w:= 1 to 2 do for z:= 1 to 3 do case (w+z) mod 4 of 1: x:=x+1 ; 2: y:=y+1; 3: x:= x - 1; 0: y := y -1; end; write(x:6, y:6); writeln; end. Case dry run #2

5 Fix the following Casefix.pas from the class website.

6 Program options Case #2 Fast Food Menu
Put at least three items on your menu (Big Mac, Coke, Vegan Burger, …) Assign a price for each. Let the user select as many items as they would like. (Use a menu, case and repeat..until loop) When they have finished ordering, show their total bill. Random Fractal Image Input: The x and y coordinates for a point on the screen. Process: Randomly pick one of three corners of a triangle that would fit on the screen Place a dot halfway between the current point and the corner selected. Repeat this process using the new dot as the starting point for selecting the next dot. Generate 1000 dots. What is the image? Is it different if you select different starting points? Push: Try this with a square, pentagon, …


Download ppt "10/27/2016 Dry Run 2 Case Programs Fix it Second Case Program"

Similar presentations


Ads by Google