Download presentation
Presentation is loading. Please wait.
Published byMadeleine Cobb Modified over 8 years ago
2
CHAPTER #6 Problem Solving with Case Structure
3
Overview Case logical structure Code Menu
4
Objectives Develop problems using the case logic structure Use problem-solving tools when developing a solution using the case logic structure
5
Background Sometimes a solution to a problem requires the computer to select one action from a set of actions
6
Menu What is a menu? – option/case What you have to do with menu? – select/decide Does everything appears on menu? –not it doesn’t What if your choice doesn’t exist? –going home, find another menu/default action (optional)
7
Critical Thinking This kind of solution can be designed through the decision logic structure But the case logic structure is more efficient for this purpose The case logic structure is a special variation of the decision structure
8
How it appears? This structure is used in many business- related problems, such as those dealing with types of accounts in a bank, types of insurance available to an employee, or the selection of a bonus. Etc. We will make a menu using Case structure
9
General Form of Case Logic Structure CaseOf actions for actions for... Otherwise: actions when all other conditions are False EndOfCase This symbols indicated that there might be presents soo many ‘options’
10
Figure 6.17 Flowchart Diagram for the Case Logic Structure
11
Figure 6.18 Alternate Flowchart Diagram for the Case Logic Structure
12
How to decide? We use CODES Codes are characters, character strings, numbers, or some combination of these types of data to name the options, the constants, in a case structure Abbreviations for each of the options Example : B for Best Medical Insurance Company, D for Direct Medical Insurance Company, and the like
13
Codes as Indicators A code is used to indicate choices Ex : The type of insurance an employee is buying, the gender of an individual, or the vendor in an inventory problem When using codes, the Otherwise option indicates an error Without the use of codes, solutions requiring a choice from among several options would be longer, harder to read, and more difficult to maintain.
14
Problem A company has four different medical plans. The programmer has given each plan a code corresponding to the beginning initial of the company: Plan 1 = F Plan 2 = B Plan 3 = K Plan 4 = E
15
Problem (cont.) The company pays for all of Plan 1. The individual has to pay for part of the others. The payroll deduction for Plan 2 = 4.65, for Plan 3 = 7.85 and for Plan 4 = 5.50 Any other codes are considered in error. Write the algorithm and draw the flowchart for a module to determine the payroll deduction
16
Using Codes - InsuranceDeduction
17
Example Foods Menu 1.Soto 2.Sate 3.Soup 4.Exit Enter your choice : _
18
Conclusion What is Case structure? How do this differs from decission structure? Could you implement this structur for creating menu? Make sure you have choose what is your code use.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.