This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.

Slides:



Advertisements
Similar presentations
Team Leads Orientation to the Activity Tracker. Thank you for becoming an Active U Team Lead This presentation has been developed to orient you to the.
Advertisements

CSE 1301 Lecture 5B Conditionals & Boolean Expressions Figures from Lewis, “C# Software Solutions”, Addison Wesley Briana B. Morrison.
Using Schoolnet: Creating an Express Test Workshop Mike Antrim Woodbridge Technology Advisory Committee 1.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
Chapter 7: User-Defined Functions II Instructor: Mohammad Mojaddam.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
True or false A variable of type char can hold the value 301. ( F )
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 5 Looping.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
Display a 12-Month Calendar CS-2301 D-term Programming Assignment #2 12-Month Calendar CS-2301 System Programming C-term 2009 (Slides include materials.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
1 Lab Session-6 CSIT-121 Spring 2005 Structured Choice The do~While Loop Lab Exercises.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
1 Lab Session-7 CSIT-121 Fall Introducing Structured Choice 4 The do~While Loop 4 Lab Exercises.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
Assignment #2, 12- month Calendar CS-2301, B-Term Programming Assignment #2 12-Month Calendar CS-2301, System Programming for Non-Majors (Slides.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 9P. 1Winter Quarter Switch Case Structures.
Basic Navigation in SAP For the Windows Graphical User Interface (GUI) Click your mouse anywhere or select “Page Down” to scroll through the pages.
Smart Data OnLine Training
While Loops Indefinite Iteration. Last lesson we looked at definite loops using the ‘For’ statement. The while loop keeps going while some condition is.
Instructors begin using McGraw-Hill’s Homework Manager by creating a unique class Web site in the system. The Class Homepage becomes the entry point for.
CP104 Introduction to Programming Selection Structures_3 Lecture 11 __ 1 The Switch Statement The switch statement provides another means to select one.
CPS120: Introduction to Computer Science Decision Making in Programs.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition, Fifth Edition Chapter 7: User-Defined Functions II.
CMPS 1371 Introduction to Computing for Engineers MatLab.
Chapter 8 Repetition Statements. Introduction Iteration - process of looping or the repetition of one or more statements Loop body - the statement, or.
Copyright © 2012 Pearson Addison-Wesley. All rights reserved. CIS_IS20_CSLO 1. Explain computer programming concepts CSLO1.6. Explain the purpose of general.
Early Childhood Outcomes Indicator 7 Data Collection Application Review.
1 PowerPoint II Slide Transitions, Animations, and Links.
GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 1 Other GUI components In this section, we will.
Data Structure and c K.S.Prabhu Lecturer All Deaf Educational Technology.
CSCI 171 Presentation 5. The while loop Executes a block as long as the condition is true general form: while (condition) { statement 1; statement 2;
Ceridian Time Solutions Hourly/Non-Exempt & (Non- Contracted) Per Diems Key Entry.
Message: "You are mature"
1 CS161 Introduction to Computer Science Topic #8.
Indicator 13 Secondary Transition. Main Menu SPP13 has a navigation toolbar located at the top of each screen. If you use the toolbar to navigate to another.
CS 1430: Programming in C++.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 5 Looping.
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 2: Fundamental Programming Structures in Java Adapted from MIT AITI Slides Control Structures.
February 7, You have seen how If statement works from last week’s activities. You have learned that If statement is a conditional statement. Today,
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
User-Written Functions
Chapter 7: User-Defined Functions II
Chapter 8 Repetition Statements
MON TUE WED THU
2008 Calendar.
Looping III (do … while statement)
C Programming Getting started Variables Basic C operators Conditionals
SELECTIONS STATEMENTS
Sun Mon Tue Wed Thu Fri Sat
Sun Mon Tue Wed Thu Fri Sat
1/○~1/○ weekly schedule MON TUE WED THU FRI SAT SUN MEMO
2016 | 10 OCT SUN MON TUE WED THU FRI SAT
Sun Mon Tue Wed Thu Fri Sat
Switch Case Structures
2008 Calendar.
HOW TO CREATE A REGULAR [Mon-Fri] SCHEDULE
Presentation transcript:

This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed. If you have opened this lesson in PowerPoint, use the PowerPoint menus to view it in slide show mode. If you have opened this lesson in a browser and see a bar similar to that below, click on the Slide Show icon A notice similar to the one below may appear warning that ActiveX or other scripts are disabled. Enable the controls for this website in order to see the animations.

Menus Christine S. Wolfe Ohio University Lancaster 2008-Aug-01 This lesson introduces a well-known algorithm for using a menu to interact with the user.

A menu program is one that presents the user with a list of choices. The user enters a value in order to select one of the choices. Processing continues based on the value selected. At the end of processing the user's selection, control returns to the menu. The program ends when the user selects an exiting option. Computer Learning Center Please select one of the following options: 1) Enter new employee profile 2) Edit employee profile 3) Enter work schedule 0) Quit Response:

The central part of a menu program is implemented via a switch statement. Computer Learning Center Please select one of the following options: 1) Enter new employee profile 2) Edit employee profile 3) Enter work schedule 0) Quit Response:

When using a switch, the user responses are limited to ints and chars. Why? Are there other advantages to limiting the choices to ints and chars? Computer Learning Center Please select one of the following options: 1) Enter new employee profile 2) Edit employee profile 3) Enter work schedule 0) Quit Response:

Computer Learning Center Please select one of the following options: 1) Enter new employee profile 2) Edit employee profile 3) Enter work schedule 0) Quit Response: 3 Computer Learning Center Enter work schedule: Employee ID: 123 Mon: 8 Tue: 8 Wed: 8 Thu: 8 Fri: 8 Sat: 8 Sun: 8 Typically, at the end of processing an option, control is returned to the menu. Computer Learning Center Please select one of the following options: 1) Enter new employee profile 2) Edit employee profile 3) Enter work schedule 0) Quit Response:

Computer Learning Center Edit employee profile: Employee ID: 123 First Name: Mike Last Name: Smith SSN: Date of Birth: Date of Hire: Typically, at the end of processing an option, control is returned to the menu and the process starts all over again. Computer Learning Center Please select one of the following options: 1) Enter new employee profile 2) Edit employee profile 3) Enter work schedule 0) Quit Response: Computer Learning Center Enter work schedule: Employee ID: 123 Mon: 8 Tue: 8 Wed: 8 Thu: 8 Fri: 8 Sat: 8 Sun: 8 Computer Learning Center Enter new employee profile: Employee ID: First Name: Last Name: SSN: Date of Birth: Date of Hire: Which logic structure causes the program to execute a set of code over and over again?

The menu processing switch is nested inside a loop and becomes the body of the loop. Initialize the test The test Affect the test

Arithmetic Menu +) Addition -) Subtraction *) Multiplication /) Division %) Modulo Q) Quit Enter the symbol for your selection or Q to quit Another Example, this one with code…

Operator = Menu(); while (Operator != 'q' && Operator != 'Q') { switch (Operator) { case '+':Result = Addition(); ++NumAttempt; NumCorrect = NumCorrect + Result; break; [NOTE: to save space, the other cases are not shown here.] default: printf("\nInvalid Entry."); fflush(stdin); getchar(); } Operator = Menu(); } Menus are implemented as a switch inside a loop.

/* FUNCTION PROTOTYPES */ char Menu(void); int Addition(void); int Subtraction(void); int Multiplication(void); int Division(void); int Modulo(void);

char Menu(void) { char Choice; /* MENU SELECTION MADE BY THE USER */ /* DISPLAY THE MENU */ system("cls"); printf("\n\n"); printf("\nArithmetic Menu\n"); printf("\n+) Addition"); printf("\n-) Subtraction"); printf("\n*) Multiplication"); printf("\n/) Division"); printf("\n%) Modulo"); printf("\nQ) Quit"); /* PROMPT FOR USER SELECTION */ printf("\n\nEnter the symbol for your selection or Q to quit "); scanf("\n%c", &Choice); return Choice; }

int Addition(void) { /* PERFORM ADDITION */ float Operand1; float Operand2; float PlayerAnswer; float CorrectAnswer; system("cls"); printf("\nEnter the first operand "); fflush(stdin); scanf("\n%f", &Operand1); printf("\nEnter the second operand "); fflush(stdin); scanf("\n%f", &Operand2); printf("\nEnter your answer to the problem: %f + %f = ", Operand1, Operand2); fflush(stdin); scanf("\n%f", &PlayerAnswer); continued on the next slide

CorrectAnswer = Operand1 + Operand2; if (PlayerAnswer == CorrectAnswer) { printf("\n\nCorrect!!!. Hit any key to return."); fflush(stdin); getchar(); return 1; } else { printf("\n\nSorry. The correct answer is %f", CorrectAnswer); fflush(stdin); getchar(); return 0; } } /* this curly brace closes the body of the function definition the opening brace is on the previous slide */