CIS 115 Lecture 4.  Create a Windows-based application that will calculate the Gross Pay earned for a worker, given the number of hours worked and hourly.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

Introduction to Programming and Visual Basic 2005
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 1- 1 STARTING OUT WITH Visual Basic 2008 FOURTH EDITION Tony Gaddis.
An Introduction to Visual Basic Terms & Concepts.
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter Introduction to Programming and Visual Basic
Creating an OOED Application
1.
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
IMS1906 Programming in VB.NET Week 3 – Lecture 1 Application Development © Angela Carbone Monash University School of Information Management.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 1- 1.
Chapter 1 Introduction to Programming and Visual Basic 2005 Lecture Notes Chapter 1 (CSIT 105)
Chapter Introduction to Programming and Visual Basic
Copyright © 2001 by Wiley. All rights reserved. Chapter 1: Introduction to Programming and Visual Basic Computer Operations What is Programming? OOED Programming.
CIS 115 Lecture 2.  Visual Studio 2005 Professional Edition (Requires Windows XP Pro)  MSDN Library for Visual Studio 2005 Available from MSDNAA.
Introduction to Programming and Visual Basic
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Chapter 1 Introduction to Programming and Visual Basic.
CSCI Programming with Visual Basic Instructor: Bindra Shrestha University of Houston – Clear Lake.
Copyright © 2001 by Wiley. All rights reserved. Chapter 3: Variables, Assignment Statements, and Arithmetic Variables Assignment Statements Arithmetic.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
Chapter 2 Build Your First Project A Step-by-Step Approach 2 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
1 Integrated Development Environment Building Your First Project (A Step-By-Step Approach)
Learning Objectives Data and Information Six Basic Operations Computer Operations Programs and Programming What is Programming? Types of Languages Levels.
Overview-An Overview of Visual Basic.NET1 An Overview of Visual Basic.NET.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 1B Introduction (Tutorial)
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
Problem Create a Windows-based application that will calculate the Gross Pay earned for a worker, given the number of hours worked and hourly pay rate.
Clearly Visual Basic: Programming with Visual Basic 2008
Intro to Programming and Visual Basic .NET
Visual Basic Week 2
Starting Out with Visual Basic.NET 2 nd Edition Chapter 1 Introduction to Programming and Visual Basic.NET.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Copyright © 2014 Pearson Education, Inc. Chapter 1 Introduction to Programming and Visual Basic.
Programming with Visual C++: Concepts and Projects Chapter 2B: Reading, Processing and Displaying Data (Tutorial)
COPYRIGHT 2007: Dr. David Scanlan, CSUS 010-HELLO WORLD VB-Express.ppt Purpose: A "Hello World" program's purpose is to eliminate as much complexity as.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Managing Controls Lab 2 2 All Rgihs ReservedIsmail M. Romi – PPu: IT DEpt.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.
What is Visual Basic.NET? 110 B-1 e.g. a word processor doesn’t do anything until the user clicks on a button, types text... A programming language that.
1 Original Source : and Problem and Problem Solving.ppt.
Copyright © 2011 Pearson Addison-Wesley What is a Program Made Of? Keywords (Reserved Words) – Words with special meaning that make up a high-level programming.
1.
Chapter One An Introduction to Programming and Visual Basic.
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Chapter 1 Introduction to Programming and Visual Basic.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
CS 2340: Programming in VB Lab 2 Due 9 pm, Friday, September 14 1.
5.01 Understand Different Types of Programming Errors
Steps for Developing a Visual C# 2010 Application MIT By: S. Sabraz Nawaz.
Visual Basic.NET Programming for the Rest of Us Keith Mulbery Utah Valley State College.
Visual Basic.Net. Software to Install Visual Studio 2005 Professional Edition (Requires Windows XP Pro) MSDN Library for Visual Studio 2005 Available.
COMPUTER PROGRAMMING I SUMMER Understand Different Types of Programming Errors.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are used in programs so that values can be represented with.
© 2006 Lawrenceville Press Slide 1 Chapter 4 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration statement. For example: Dim.
Chapter 2 Build Your First Project A Step-by-Step Approach 2 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
Chapter 1 Introduction to Programming and Visual Basic.
5.01 Understand Different Types of Programming Errors
Introduction to Programming and Visual Basic
Chapter 1. Introduction to Computers and Programming
Introduction to Programming and Visual Basic
An Introduction to Visual Basic
Introduction to Programming and Visual Basic
5.01 Understand Different Types of Programming Errors
CIS16 Application Development Programming with Visual Basic
STARTING OUT WITH Visual Basic 2008
Chapter 2- Visual Basic Schneider
Chapter One: An Introduction to Programming and Visual Basic
Presentation transcript:

CIS 115 Lecture 4

 Create a Windows-based application that will calculate the Gross Pay earned for a worker, given the number of hours worked and hourly pay rate.

 Clearly define the problem and identify what the program is to do  Purpose: To calculate a worker’s gross pay  Input: Number of hours worked, hourly pay rate  Process: Multiply number of hours worked by hourly pay rate (result is the user’s gross pay)  Output: Display a message indicating the user’s gross pay

Traditional Procedural Approach - Develop an algorithm:  Display message: "How many hours did you work?"  Allow user to enter number of hours worked  Store the number the user enters in memory  Display message: "How much are you paid per hour?"  Allow the user to enter an hourly pay rate  Store the number the user enters in memory  Multiply hours worked by pay rate and store the result in memory  Display a message with the result of the previous step This well-defined, ordered set of steps for solving a problem is called an algorithm.

VB (GUI) Approach – Identify required controls and events/handlers  Inputs - entered into the program via Controls:  Hours Worked  Hourly Pay Rate  Processes - initiated by Events and carried out by the code contained in the corresponding Event Procedures:  Calculate Gross Pay ▪ Gross Pay = hoursWorked * hourlyPayRate  Output - displayed to the user via Controls:  Gross Pay

 Inputs (controls):  Hours Worked  Textbox, Label (title/prompt)  Hourly Pay Rate  Textbox, Label (title/prompt)  Processes (events/event procedures):  Calculate Gross Pay  Button(click) ▪ Gross Pay = hoursWorked * hourlyPayRate  Exit Program  Button(click) ▪ End  Outputs (controls):  Gross Pay Earned  Label (display result), Label (title)

Design the Interface – TOE Chart  Task, Object, Event  Plan the interface BEFORE creating in VB  Examines all of the tasks involved in solution Task (T)Object (O)Event (E) Input Hours WorkedTextbox, LabelNone Input Pay RateTextbox, LabelNone Output Gross PayLabel (display), Label (title) None Calculate Gross PayButtonClick Exit ProgramButtonClick

 Make a list of the controls needed  Define values for each control's relevant properties: Control TypeControl NameText Form(Default)"Wage Calculator" TextBoxtxtHoursWorked"" Label(Default)"Number of Hours Worked" TextBoxtxtPayRate"" Label(Default)"Hourly Pay Rate" LabellblGrossPay"$0.00" Label(Default)"Gross Pay Earned" ButtonbtnCalcGrossPay"Calculate Gross Pay" ButtonbtnExit“Exit"

 Make a list the events/procedures needed  Develop an algorithm for each procedure EventEvent Procedure Code Algorithm btnCalcGrossPay_ClickGet hours worked from txtHoursWorked Get hourly pay rate from txtPayRate Multiply hours worked by hourly pay rate Assign result to lblGrossPay btnClose_ClickEnd the application

 Visualize the application running on the computer and design its user interface

 Creating the Visual Basic Application - Event Driven Programming Steps  Create the Interface / Window first ▪ Input ▪ Output  Set the Properties ▪ Configure the appearance and behavior of the controls  Then Code the Application ▪ Processes - Event Handing Methods

 Create the Interface - Use Visual Basic to create the forms and other controls identified in the previous step  This is the first use of Visual Basic, all of the previous steps have just been on paper  In this step you develop the portion of the application the user will see Label Text Box Label 2 Buttons

 Set Properties - Use Visual Basic to set properties for the forms and other controls from list you made earlier  In this step you still developing the portion of the application the user will see Control TypeControl NameText Form(Default)"Wage Calculator" TextBoxtxtHoursWorked"" Label(Default)"Number of Hours Worked" TextBoxtxtPayRate"" Label(Default)"Hourly Pay Rate" LabellblGrossPay"$0.00" Label(Default)"Gross Pay Earned" ButtonbtnCalcGrossPay"Calculate Gross Pay" ButtonbtnExit“Exit"

 Create the Events/Procedures - Use Visual Basic to create and write the code for the event procedures identified earlier  In this step you develop the methods behind the click event for each button  Unlike the interface, this portion of the application is invisible to the user

 btnCalculate  Button Click Event  Assignment statement  lblGrossPay.text = Val(txtHoursWorked.text) * Val(txtPayRate.text) ▪ Gets data from txtHoursWorked.text and txtPayRate.text ▪ Assigns results from hours * rate calculation to lblGrossPay.text  Val changes the text input from the text box into a number

 btnExit  Button Click Event  End

3 Major Types of Errors  Syntax Errors – Language Errors  Caught by the Compiler & Interpreter  Visual Basic – wavy line under problem code  Run-Time Errors  Program will not run to normal completion  Program Crashes  Logic Errors  Program Runs but produces incorrect results

 Attempt to run the application - find syntax errors and runtime errors  Correct any syntax errors found – indicated by wavy blue line  All syntax errors must be removed before Visual Basic will create a program that actually runs  Find and correct and correct any runtime errors until program runs to normal completion

 Run the application using test data as input  Run the program with a variety of test data  Must test for expected and unexpected input ▪ negative numbers, blank text box, etc. ▪ will talk about how to deal with invalid input later  Check the results to be sure that they are correct  Correct any logic errors found  Repeat this step as many times as necessary

 Homework 2  Visual Basic Application  See handout for details and due date  Questions?