© Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 7.1 Test-Driving the Wage Calculator Application.

Slides:



Advertisements
Similar presentations
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 12 – Security Panel Application Introducing.
Advertisements

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 10 – Enhancing the Wage Calculator Application:
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 21 - “Cat and Mouse” Painter Application.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 16 – Craps Game Application Introducing Random-Number.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Introducing Algorithms, Pseudocode and.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 8 - Interest Calculator Application: Introducing.
Chapter 7 – Control Structures A payroll company calculates the gross earnings per week of employees. Employees’ weekly salaries are based on the number.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 9 – Income Tax Calculator Application: Introducing.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 6 – Car Payment Calculator Application: Introducing.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 6.1 Test-Driving the Wage Calculator Application.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 9 Car Payment Calculator Application Introducing the Do While...Loop and Do Until...Loop.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - Welcome Application: Introduction to C++
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Interest Calculator Application Introducing the For...Next Repetition Statements.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Typing Application Introducing Keyboard Events, Menus, Dialogs and the Dictionary.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 8 - Interest Calculator Application: Introducing.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 30 – Bookstore Application: Client Tier Examining.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 10 – Enhancing the Wage Calculator Application:
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Enhancing the Wage Calculator Application Introducing Function Procedures and.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Wage Calculator Application: Introducing.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Structural Program Development: If, If-Else Outline.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 27 - Phone Book Application Introducing Multimedia.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 5 – Dental Payment Application: Introducing.
Copyright © 2001 by Wiley. All rights reserved. Chapter 4: The Selection Process in Visual Basic Selection Process Two Alternative Structure If..Then..ElseIf.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Flow Control (Switch, do-while, break) Outline 4.7The.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 8 Dental Payment Application Introducing CheckBox es and Message Dialogs.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 9 – Income Tax Calculator Application: Introducing.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 6 – Car Payment Calculator Application: Introducing.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 5 Completing the Inventory Application Introducing Programming.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 17 – Flag Quiz Application Introducing One-Dimensional.
Programming with Visual C++: Concepts and Projects Chapter 2B: Reading, Processing and Displaying Data (Tutorial)
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Security Panel Application Introducing the Select Case Multiple-Selection Statement.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 3.1 Test-Driving the Welcome Application 3.2.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Class Average Application Introducing the Do...Loop While and Do...Loop Until.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 7 – Class Average Application: Introducing.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 21 - “Cat and Mouse” Painter Application.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 20.1 Test-Driving the Shipping Hub Application.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 12 – Enhancing the Wage Calculator Application.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 25.1 Test-Driving the ATM Application 25.2.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 18 – Student Grades Application Introducing.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 5.1 Test-Driving the Inventory Application.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 15 – Fund Raiser Application Introducing.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 3 – Inventory Application: Introducing Variables,
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 3 – Inventory Application: Introducing Variables,
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 24.1 Test-Driving the Enhanced Car Payment.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Craps Game Application Introducing Random-Number Generation and Enum.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 5.1 Test-Driving the Enhanced Inventory Application.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Student Grades Application Introducing Two-Dimensional Arrays and RadioButton.
 2003 Prentice Hall, Inc. All rights reserved. 1 Will not cover 4.14, Thinking About Objects: Identifying Class Attributes Chapter 4 - Control Structures.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 16 – Craps Game Application Introducing Random-Number.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 7 Wage Calculator Application Introducing Algorithms, Pseudocode and Program Control.
 2003 Prentice Hall, Inc. All rights reserved. 1 Outline 11.1 Test-Driving the Interest Calculator Application 11.2 Essentials of Counter-Controlled Repetition.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Enhanced Car Payment Calculator Application Introducing Exception Handling.
Tutorial 10 – Class Average Application Introducing the Do…Loop While and Do…Loop Until Repetition Statements Outline Test-Driving the Class Average.
13 Enhancing the Wage Calculator App
Tutorial 12 – Security Panel Application Introducing the Select Case Multiple-Selection Statement Outline Test-Driving the Security Panel Application.
Chapter 3: Introduction to Problem Solving and Control Statements
MSIS 655 Advanced Business Applications Programming
Presentation transcript:

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 7.1 Test-Driving the Wage Calculator Application 7.2 Algorithms 7.3 Pseudocode 7.4 Control Structures 7.5 if Selection Statement 7.6 if…else Selection Statement 7.7 Constructing the Wage Calculator Application 7.8 Assignment Operators 7.9 Formatting Text 7.10 Using the Debugger: The Watch Window 7.11 Wrap-Up Tutorial 7 – Wage Calculator Application Introducing Algorithms, Pseudocode and Program Control

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 2 Objectives In this tutorial, you will learn to: –Understand basic problem-solving techniques. –Understand control structures. –Understand and create pseudocode. –Use the if and if…else selection statements to choose among alternative actions. –Use the assignment operators. –Use the debugger’s Watch window.

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Test-Driving the Wage Calculator Application

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Test-Driving the Wage Calculator Application Load the Wage Calculator application –Debug > Start –Notice the alignment of the TextBox es Figure 7.1 Wage Calculator application.

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Test-Driving the Wage Calculator Application Initializing TextBox fields –Set Hourly wage: TextBox to 10 –Set Weekly hours: TextBox to 45 –Click Calculate Button Figure 7.2 Calculating wages by clicking the Calculate Button.

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Algorithms An algorithm –Actions –Order in which the actions occur Program control

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Pseudocode Pseudocode –Informal language Everyday English Describes only executable statements Not a programming language –Helps plan algorithms and programs

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Control Structures Three control structures –Sequence structure –Selection structure –Repetition structure Activity diagram –Models the workflow

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Control Structures Figure 7.3 Sequence structure activity diagram.

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved if Selection Statement

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved if Selection Statement

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved if Selection Statement Figure 7.6 if single-selection statement activity diagram.

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved if…else Selection Statement

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved if…else Selection Statement Figure 7.8 if…else double-selection statement activity diagram.

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved if…else Selection Statement Pseudocode for an application that displays a student’s grades. If student’s grade is greater than or equal to 90 Display “A” Else If student’s grade is greater than or equal to 80 Display “B” Else If student’s grade is greater than or equal to 70 Display “C” Else If student’s grade is greater than or equal to 60 Display “D” Else Display “F”

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved if…else Selection Statement C# code converted from pseudocode if ( intStudentGrade >= 90 ) { lblDisplay.Text = "A"; } else { if ( intStudentGrade >= 80 ) { lblDisplay.Text = "B"; } else { if ( intStudentGrade >= 70 ) { lblDisplay.Text = "C"; } else { if ( intStudentGrade >= 60 ) { lblDisplay.Text = "D"; } else { lblDisplay.Text = "F"; } } } }

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved if…else Selection Statement if…else statement using the else if structure. if ( intStudentGrade >= 90 ) { lblDisplay.Text = "A"; } else if ( intStudentGrade >= 80 ) { lblDisplay.Text = "B"; } else if ( intStudentGrade >= 70 ) { lblDisplay.Text = "C"; } else if ( intStudentGrade >= 60 ) { lblDisplay.Text = "D"; } else { lblDisplay.Text = "F"; }

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Wage Calculator Application

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Wage Calculator Application Generating the btnCalculate_Click event handler –Button calculates gross earnings

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Wage Calculator Application Figure 7.10 Calculate Button event handler. Generated event handler

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Wage Calculator Application Declaring variables –Primitive data types double decimal

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Wage Calculator Application Figure 7.11 Declaring variables of type double and d ecimal. Variable declarations

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Wage Calculator Application Declaring a constant variable –Keyword c onst –Value set at declaration and cannot be changed thereafter

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Wage Calculator Application Figure 7.12 Creating a constant. Constant declaration

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Wage Calculator Application Assigning data to variables –Double.Parse method –Decimal.Parse method

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Wage Calculator Application Figure 7.13 Assigning data to variables. Variable assignment

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Wage Calculator Application Determining wages –Use if…else statement Regular wage Time and half for overtime

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Wage Calculator Application Figure 7.14 i f…else statement to determine wages. Added if…else statement

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Wage Calculator Application Displaying output –Using Label ’s Text property

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Wage Calculator Application Figure 7.15 Assigning the result to lblEarningsResult. Displaying output

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Wage Calculator Application Figure 7.16 Running the application before formatting the output. Displaying output

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Assignment Operators

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Assignment Operators Using the assignment operator –Makes statement shorter

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Assignment Operators Figure 7.18 Using the addition assignment operator in a calculation. Assignment operator shortens statement

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Formatting Text Formatting output –Use Format specifier –Use C for currency

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Formatting Text Figure 7.19 Using the Format method to display the result as currency. Formatting output as currency

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Formatting Text

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 38 WageCalculator.cs (1 of 5)

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 39 WageCalculator.cs (2 of 5)

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 40 WageCalculator.cs (3 of 5)

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 41 WageCalculator.cs (4 of 5) Condition after keyword if Keyword const specifies constant else body executes when condition evaluates to false

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 42 WageCalculator.cs (5 of 5) Format result as currency Assignment operator assigns left operand result of adding left and right operands

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: The Watch Window Using the debugger –Set breakpoints

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: The Watch Window Figure 7.22 Breakpoints added to Wage Calculator application.

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: The Watch Window Suspending program execution –Run the application –IDE switch to break mode –Active window changes Figure 7.23 Suspending program execution.

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: The Watch Window Examine data –Enabling the Watch window The Name column The Value column The Type column Figure 7.24 Watch window. Variable typesVariable values Variable names

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: The Watch Window Examining different expressions –Evaluating arithmetic expressions –bool expressions –Invalid expressions Figure 7.25 Examining expressions. Invalid expression bool expressionComplex expression

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: The Watch Window Deleting a watch Figure 7.26 Deleting a watch. Delete Watch option

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: The Watch Window Changes to the Watch window –Modified values displayed in red Figure 7.27 Modified values in Watch window. Modified value appears in red

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: The Watch Window Changing a variable’s value –Test various values to confirm behavior of the application Figure 7.28 Modifying values in a Watch window. Value modified directly

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: The Watch Window Noting the changes to the variable’s values –Allow the debugging process to continue Figure 7.29 Dialog to continue running application after changing values in the Watch window.

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: The Watch Window Notice the result from the debugging process Figure 7.32 Output displayed after the debugging process. Earnings result based on altered input