Presentation is loading. Please wait.

Presentation is loading. Please wait.

Design Document Sample Given two concentrated circles with different radii, calculate the area which falls inside the big circle but outside the small.

Similar presentations


Presentation on theme: "Design Document Sample Given two concentrated circles with different radii, calculate the area which falls inside the big circle but outside the small."— Presentation transcript:

1 Design Document Sample Given two concentrated circles with different radii, calculate the area which falls inside the big circle but outside the small circle (cyan part in the graph) - to be continued … Specify the Requirement

2 Data Analysis NameTypeContent ConstantsPIreal3.14 VariablesradiusOfSmallCirclerealradius of the small circle radiusOfBigCirclerealradius of the big circle areaOfSmallCirclerealarea of the small circle areaOfBigCirclerealarea of the big circle areaToBeCalculated realarea of the requested part - to be continued …

3 Problem Analysis Prompt User for the input of radiusOfSmallCircle Read radiusOfSmallCircle Prompt User for the input of radiusOfBigCircle Read radiusOfBigCircle Calculate areaOfSmallCircle Calculate areaOfBigCircle Calculate areaToBeCalculated by substracting areaOfSmallCircle from areaOfBigCircle Output areaToBeCalculated - to be continued …

4 Algorithm (Pseudocode) print “Enter radius of the small circle: ” read radiusOfSmallCircle print “Enter radius of the big circle: ” read radiusOfBigCircle areaOfSmallCircle = PI * radiusOfSmallCircle * radiusOfSmallCircle areaOfBigCircle = PI * radiusOfBigCircle * radiusOfBigCircle areaToBeCalculated = areaOfBigCircle - areaOfSmallCircle print “the area to be calculated is: ”, areaToBeCalculated - to be continued …

5 Trace Table radiusOfSmallCircleradiusOfBigCircle areaToBeCalculated 1.02.0 9.42 0.52.5 6.28 2315.70 0.6449.74 0250.24 00 0.00 -11 0.00 66 0.00 2.50.5-6.28 - end.

6 Types of Statements - Sequential Statement Definition: Statements which are complete within themselves. These Statements neither iterate nor check conditions. e.g. 1. print “Enter radius of the small circle: ” 2. read radiusOfSmallCircle or get radiusOfSmallCircle or input radiusOfSmallCircle 3. areaOfSmallCircle = PI * radiusOfSmallCircle * radiusOfSmallCircle 4. output areaToBeCalculated or print areaToBeCalculated or write areaToBeCalculated

7 Types of Statements - Conditional Statement Defintion: Statements having a choice of operation expressed within them. if (condition) then perform operation (1) // condition is met else perform operation (2) // condition is not met e.g. if (gender = ‘M’) then print “Hello, Sir.” else print “Hello, Madam.” - to be continued …

8 Types of Statements - Conditional Statement If more choices are needed … e.g. if (CountryCode = ‘A’) then print “America” else if (CountryCode = ‘B’) then print “British” else if (CountryCode = ‘C’) then print “China” else if (CountryCode = ‘D’) then print “Denmark” else print “Sorry, I do not know the answer”

9 Types of Statements - looping/iterative Statement Definition: Statement which enforce repetition. Three MUST steps: -INITIALIZE the loop correctly -CONTINUE the loop correctly -STOP the loop correctly e.g. Print 10 times “Hello, World” count = 0 while (count = 10 begin print “Hello, World” // the operations to be repeated count = count +1 end - to be continued …

10 Types of Statements - looping/iterative Statement Counter-controlled loops: a count controls the loop until a limit is reached. Three MUST steps: -INITIALIZE the counter correctly -UPDATE the counter correctly -CHECK the counter to decide whether to CONTINUE or STOP repeating e.g. Print 10 times “Hello, World” count = 0 while (count = 10 begin print “Hello, World” // the operations to be repeated count = count +1 end - to be continued …

11 Types of Statements - looping/iterative Statement Sentinel-controlled loops: a variable’s value is chosen to end the loop. Three MUST steps: -INITIALIZE the variable correctly -UPDATE the variable correctly -CHECK the variable to decide whether to CONTINUE or STOP repeating e.g. Read employeeId until its value is equal to -1 read employeeId while (employeeId <>-1) // condition to STOP this loop is employeeId = -1 begin print “employeeId is ”, employeeId // the operations to be repeated read employeeId end - to be continued …


Download ppt "Design Document Sample Given two concentrated circles with different radii, calculate the area which falls inside the big circle but outside the small."

Similar presentations


Ads by Google