Download presentation

Presentation is loading. Please wait.

Published byKeven Homsey Modified over 2 years ago

1
Quiz 1

2
What is the Output of this code fragment when N = 85 (3 Marks) [5 Minutes] A = N \ 10 B = N Mod 10 C = 0 If (N Mod 2 = 0) Then C = C + 1 Else C = C + 2 End If If (A > 5) And (B > 5) Then C = C + 3 ElseIf (A > 5) Or (B > 5) Then C = C + 5 Else C = C + 6 End If N = B * 100 + C * 10 + A MsgBox ("N = " & N)

3
Example 1 Cones and Cylinders

4
Problem 1 Find the surface area of a cylinder with a given radius and height Area of top and bottom is a circle –Area Top = Area Bottom = r 2 Area of side Circumference * Height –Area Side = 2 rh Total Area –Area = 2 r 2 + 2 rh = 2 r (r + h)

5
Algorithm Cylinder Name : Cylinder Given : r h Results : A Intermediate : None Definition –A := Cylinder(r, h) Get r Get h A = 2 r(r + h) Give A

6
Problem 2 Find the surface area of a cone, of given radius and height Area = r (r + s) –Where s = (r 2 + h 2 ) This came from an internet research

7
Cone Algorithm Name : Cone Given : r, h Results : A Intermediate: S Definition –A := Cone (r, h) Get r Get h s = sqrt(r^2 + h^2) A = r (r + s) Give A

8
Problem 3 You are in charge of ordering supplies for Fennell Funnel Co. You need to order the plastic pellets for the manufacturing process. Calculate the volume of plastic needed if you know, –the diameter of the top, and bottom –the length of the cone, and the spout –the thickness of the walls You may assume the “extra” is needed in the manufacturing process

9
Funnel Algorithm Name: Funnel Given: –Dtop, Htop, Dbot, Hbot, t Results : Vol Intermediates: –Acone, Acyl Definition Vol :=Funnel(Dtop, Htop, Dbot, Hbot, t) Get Dtop, Htop Get Dbot, Hbot Get t Acone: = Cone(Dtop/2, Htop) Acyl := Cylinder(Dbot/2, Hbot) Vol = t * (Acone + Acyl) Give Vol

10
Write these three algorithms using Subroutines

11
Cylinder Get r (from a SUB) Get h (from a SUB) A = 2 r(r + h) Give A Sub Cylinder (ByVal r as Single, ByVal h as Single

12
Cylinder Get r (from a SUB) Get h (from a SUB) A = 2 r(r + h) Give A (to a SUB) Sub Cylinder (ByVal r as Single, ByVal h as Single, ByRef A as Single) Const Pi = 3.14159 A = 2*Pi*r * (r + h) End Sub

13
Cone Get r (from SUB) Get h (from SUB) s = sqrt(r^2 + h^2) A = r (r + s) Give A SUB Cone (ByVal r as Single, ByVal h as Single,

14
Cone Get r (from SUB) Get h (from SUB) s = sqrt(r^2 + h^2) A = r (r + s) Give A (to SUB) Sub Cone (ByVal r as Single, ByVal h as Single, ByRef A as Single) Const Pi = 3.14159 Dim s as Single s = (r^2 + h^2)^(1/2) A = pi * r * (r + s) End Sub

15
Funnel Get Dtop, Htop Get Dbot, Hbot Get t Acone: = Cone(Dtop/2, Htop) Acyl := Cylinder(Dbot/2, Hbot) Vol = t * (Acone + Acyl) Give Vol Sub Funnel ( ) Dim Dtop as Single Dim Htop as Single Dim Dbot as Single Dim Hbot as Single Dim t as Single Dim Acone as Single Dim Acyl as Single Dim Vol as Single Dtop = InputBox(“Dtop”) Htop = InputBox (“Htop”) Dbot = InputBox(“Dbot”) Htop = InputBox (“Hbot”) t = InputBox(“t”) Call Cone(Dtop/2, Htop, Acone) Call Cylinder(Dbot/2, Hbot, Acyl) Vol = t * (Acone + Acyl) MsgBox (“Vol = “ & Format(Vol,0)) End Sub

16
Tools Macro Run Funnel View –ToolBars Command Add Button –do a Call Funnel() –Change caption to Run Macro Funnel This is not as direct as Excel

Similar presentations

OK

What is a cylinder? A cylinder is a three-dimensional shape that has two identical circular bases connected by a curved surface. Radius Circumference.

What is a cylinder? A cylinder is a three-dimensional shape that has two identical circular bases connected by a curved surface. Radius Circumference.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on ict in teaching Ppt on nature and human Ppt on metro rail in hyderabad india Free ppt on brain machine interface ethics Ppt on conceptual art drawings Ppt on ramayana in sanskrit Ppt on diodes and transistors Ppt on conservation of species Ppt on south african culture religion Ppt on sources of energy for class 8th board