Chapter Topics 11.1 Introduction to Menu-Driven Programs

Slides:



Advertisements
Similar presentations
Chapter 3: Modularization
Advertisements

Chapter 2: Modularization
ALGORITHMS THIRD YEAR BANHA UNIVERSITY FACULTY OF COMPUTERS AND INFORMATIC Lecture two Dr. Hamdy M. Mousa.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition Chapter 5: Looping by Tony.
Creating Custom Forms. 2 Design and create a custom form You can create a custom form by modifying an existing form or creating a new form. Either way,
Chapter 9 Describing Process Specifications and Structured Decisions
Switch structure Switch structure selects one from several alternatives depending on the value of the controlling expression. The controlling expression.
Program Design and Development
Repetition. Examples When is repetition necessary/useful?
1 Lab Session-6 CSIT-121 Spring 2005 Structured Choice The do~While Loop Lab Exercises.
Understanding the Mainline Logical Flow Through a Program (continued)
1 Lab Session-7 CSIT-121 Fall Introducing Structured Choice 4 The do~While Loop 4 Lab Exercises.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
The University of Texas – Pan American
REPETITION STRUCTURES. Topics Introduction to Repetition Structures The while Loop: a Condition- Controlled Loop The for Loop: a Count-Controlled Loop.
1 Chapter 9 Writing, Testing, and Debugging Access Applications.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 6 Value- Returning Functions and Modules.
Lecture Set 5 Control Structures Part D - Repetition with Loops.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
PROBLEM SOLVING WITH LOOPS Chapter 7. Concept of Repetition Structure Logic It is a computer task, that is used for Repeating a series of instructions.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Multiple Unit Multipliers Conversion of Units of Area
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 5 Repetition Structures.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Looping.
Introduction to Functions CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Lecture 7: Menus and getting input. switch Multiple-selection Statement switch Useful when a variable or expression is tested for all the values it can.
Chapter Looping 5. The Increment and Decrement Operators 5.1.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 6 1 Microsoft Office Access 2003 Tutorial 6 – Creating Custom Forms.
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
Chapter Looping 5. The Increment and Decrement Operators 5.1.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Introduction to Loop. Introduction to Loops: The while Loop Loop: part of program that may execute > 1 time (i.e., it repeats) while loop format: while.
INTRODUCTION TO PROBLEM SOLVING
MT262A Review.
REPETITION CONTROL STRUCTURE
Chapter Topics 15.1 Graphical User Interfaces
The switch Statement, and Introduction to Looping
Python: Control Structures
The Selection Structure
Chapter 5: Loops and Files.
Chapter 5: Repetition Structures
Chapter 5: Looping Starting Out with C++ Early Objects Seventh Edition
Topics Introduction to Repetition Structures
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Microsoft Office Access 2003
Chapter 5: Looping Starting Out with C++ Early Objects Seventh Edition
Microsoft Office Access 2003
Topics Introduction to File Input and Output
Exploring Microsoft Excel
Chapter 6: Repetition Structures
Chapter 5: Repetition Structures
Chapter 4: Loops and Files
Iteration: Beyond the Basic PERFORM
Chapter 3 – Control Structures
Faculty of Computer Science & Information System
© 2016 Pearson Education, Ltd. All rights reserved.
Looping III (do … while statement)
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Chapter 15: GUI Applications & Event-Driven Programming
Chapter 11 Describing Process Specifications and Structured Decisions
IPC144 Introduction to Programming Using C Week 4 – Lesson 1
Python Basics with Jupyter Notebook
This presentation document has been prepared by Vault Intelligence Limited (“Vault") and is intended for off line demonstration, presentation and educational.
Topics Introduction to Repetition Structures
Topics Introduction to File Input and Output
Presentation transcript:

Chapter Topics 11.1 Introduction to Menu-Driven Programs 11.2 Modularizing a Menu-Driven Program 11.3 Using a Loop to Repeat the Menu 11.4 Multiple-Level Menus

11.1 Introduction to Menu-Driven Programs A menu is a list of operations that are displayed by a program, in which a user can select which operations to perform Figure 11-1 A menu

11.1 Introduction to Menu-Driven Programs A decision structure can be used to perform menu selections This can be accomplished through a case structure, series of nested if-then-else statements A case structure is easier to follow the flow A case structure will provide a case for each option in the menu, in addition to a default case

11.1 Introduction to Menu-Driven Programs Figure 11-2 Flowchart for Program 11-1

11.1 Introduction to Menu-Driven Programs Validating the menu selection can be done before the case is processed, allowing for no need for a default Display “Enter your selection” Input menuSelection //validation While menuSelection < 1 OR menuSelection >3 Display “That is an invalid selection. Enter 1, 2 or 3” End While

11.2 Modularizing a Menu-Driven Program Since a menu-driven program is capable of performing many tasks, it should be put into modules A module should be written for each case that could be processed The options would simply call modules Allows for a clear flow of the program

11.2 Modularizing a Menu-Driven Program Figure 11-5 Flowchart for the main module in Program 11-3

11.3 Using a Loop to Repeat the Menu Most menu-driven programs use a loop to repeatedly display the menu after a task is performed This allows the user of the program to run another option without restarting the program The menu can also contain on option for ending the program Display “1. Convert inches to centimeters.” Display “2. Convert feet to meters.” Display “3. Convert miles to kilometers.” Display “4. End the program.”

11.3 Using a Loop to Repeat the Menu Figure 11-7 Flowchart for the main module in Program 11-5

11.4 Multiple-Level Menus A multiple-level menu has a main menu and one or more submenus Some complex programs require more than one menu A programmer should consider breaking up long menus into multiple menus This is essentially nested case structures

11.4 Multiple-Level Menus Instead of this type of long menu Process a sale Process a return Add a record to the inventory file Search for a record in the inventory file Modify a record in the inventory file Delete a record in the inventory file Print an inventory list report Print a list of inventory items by cost Print a list of inventory items by age Print a list of inventory items by retail value

11.4 Multiple-Level Menus Convert to multiple menus such as Main Menu Process a Sale or a Return Update the Inventory File Print an Inventory Report Exit the Program Sales and Returns Menu Process a Sale Process a Return Go Back to the Main Menu

11.4 Multiple-Level Menus More menus Update Inventory File Menu Add a Record Search for a Record Modify a Record Delete a Record Go Back to the Main Menu

11.4 Multiple-Level Menus More menus Inventory Report Menu Print an inventory list report Print a list of inventory items by cost Print a list of inventory items by age Print a list of inventory items by retail value Go Back to the Main Menu