Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cosc175 - Define Problem/Design Solution/Pseudocode/Trace 1 DEFINE THE PROBLEM.

Similar presentations


Presentation on theme: "Cosc175 - Define Problem/Design Solution/Pseudocode/Trace 1 DEFINE THE PROBLEM."— Presentation transcript:

1 cosc175 - Define Problem/Design Solution/Pseudocode/Trace 1 DEFINE THE PROBLEM

2 cosc175 - Define Problem/Design Solution/Pseudocode/Trace 2 Analysis of the Problem 1. Determine what is given - input =>nouns, adjectives 2. Determine what is required - output =>nouns, adjectives 3. Determine the transformations needed(processing) -actions needed to produce the required output =>verbs, adverbs

3 cosc175 - Define Problem/Design Solution/Pseudocode/Trace 3 Inputs and Outputs Determine data that is input to the problem, data that will be output from the problem Nouns We call the input and output data-variables We use a particular naming convention –No spaces –Meaningful names –Usually begin with lowercase –Examples: roomWidth, numPeople, studentName

4 cosc175 - Define Problem/Design Solution/Pseudocode/Trace 4 Example 1: Read three numbers, add them together and print the total. Step 1 – define inputs and outputs(hint: look at nouns) Break up several values into separate variables

5 cosc175 - Define Problem/Design Solution/Pseudocode/Trace 5 Example 1: Read three numbers, add them together and print the total. Step 2: define list of actions. Hint: Use verbs,these steps usually involve the input and output defined in step 1

6 cosc175 - Define Problem/Design Solution/Pseudocode/Trace 6 Example 2: Write a program to prompt the operator for the maximum and minimum temperature readings on a particular day, accept those readings as integers, and calculate and display on the screen the average temperature.

7 cosc175 - Define Problem/Design Solution/Pseudocode/Trace 7 Example 2: Write a program to prompt the operator for the maximum and minimum temperature readings on a particular day, accept those readings as integers, and calculate and display on the screen the average temperature.

8 cosc175 - Define Problem/Design Solution/Pseudocode/Trace 8 PLAN THE SOLUTION

9 cosc175 - Define Problem/Design Solution/Pseudocode/Trace 9 Plan the Solution Outline the Solution –Major processing steps involved –Major subtasks –Major control structures –Major variables and record structures –Mainline logic Develop the outline into an algorithm Test the algorithm for correctness

10 cosc175 - Define Problem/Design Solution/Pseudocode/Trace 10 Structured Programming Top Down Design & Development Modularity Control structures –sequence –selection or IF-THEN-ELSE –repetition or looping

11 cosc175 - Define Problem/Design Solution/Pseudocode/Trace 11 Design/Plan the solution Algorithm – a step by step procedure for solving a problem Programs - implementations of algorithms –Set of instructions flowcharts pseudocode –test solution for correctness - trace

12 cosc175 - Define Problem/Design Solution/Pseudocode/Trace 12 Pseudocode structured concise English statements used to state operations language independent,no standard use words and phrases that are in line with basic computer operations

13 cosc175 - Define Problem/Design Solution/Pseudocode/Trace 13 Pseudocode 1.Write statements in simple English 2.Write each instruction on a separate line. 3.Use keywords and indentation for control structures. 4.Write instructions from top to bottom, with only one entry and one exit. 5.Groups of statements may be formed into modules.

14 cosc175 - Define Problem/Design Solution/Pseudocode/Trace 14 Pseudocode 1.Input - receiving information keywords - Read, Get, Input Read - receive information from a record on a file Get - receive information from the keyboard. Read studentName Get systemDate Read num1,num2 Get taxCode use one verb followed by one or more nouns

15 cosc175 - Define Problem/Design Solution/Pseudocode/Trace 15 Pseudocode 2. Output –putting information out Put, Output,Display - screen Print - printer Write - file –Print smaller. –Print "Program Completed" –Write customer_record to file –Output totalTax –Display "End of Data"

16 cosc175 - Define Problem/Design Solution/Pseudocode/Trace 16 Output continued Labels –Display "label" statement inside quotes is printed as it appears –Display "x"// if x = 5 Yields x –Display x yields5 – Display "X = " and x yields:X = 5

17 cosc175 - Define Problem/Design Solution/Pseudocode/Trace 17 Pseudocode 3.Arithmetic use name of the operation or algebraic symbol add,subtract,multiply, divide, exponentiation + - * / ** x = algebraic expression –count = count + 1 –netPay = hourlyPayRate * hoursWorked –salesTax = cost * 0.10 –totalPrice = price + salesTax

18 cosc175 - Define Problem/Design Solution/Pseudocode/Trace 18 Pseudocode 4. Assignment - place information into a storage location Initialize, Set - give variable initial value Save,Store - save info for later = //preferred y = 3 note: does not mean equality –could involve calculation: –area = length * width


Download ppt "Cosc175 - Define Problem/Design Solution/Pseudocode/Trace 1 DEFINE THE PROBLEM."

Similar presentations


Ads by Google