GTECH 731 Lab Session 3 Lab 2 Review, Lab 3 Intro 9/20/10 Lab 2 Review Lab 3 Overview.

Slides:



Advertisements
Similar presentations
Variables in C Amir Haider Lecturer.
Advertisements

Chapter 3 DATA: TYPES, CLASSES, AND OBJECTS. Chapter 3 Data Abstraction Abstract data types allow you to work with data without concern for how the data.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 2 1 Chapter 2 Primitive.
Data Types and Expressions
CS Sept Your first C++ program… Boilerplate // Cannon, demo program #include using namespace std; int main() {// program goes here… return.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
An Introduction to Programming with C++ Fifth Edition Chapter 4 Chapter 4: Variables, Constants, and Arithmetic Operators.
An Introduction to Programming with C++ Fifth Edition Chapter 4 Chapter 4: Variables, Constants, and Arithmetic Operators.
Chapter 2: Introduction to C++.
GTECH 731 Lab Session 4 Lab 3 Review, Lab 4 Intro 9/28/10 Lab 3 Review Lab 4 Overview.
Admin Office hours 2:45-3:15 today due to department meeting if you change addresses during the semester, please unsubscribe the old one from the.
GTECH 731 Lab Session 2 Lab 1 Review, Lab 2 Intro 9/6/10 Lab 1 Review Lab 2 Overview.
1 Chapter Two Using Data. 2 Objectives Learn about variable types and how to declare variables Learn how to display variable values Learn about the integral.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
CPS120: Introduction to Computer Science Lecture 8.
***** SWTJC STEM ***** Chapter 2-2 cg Identifiers - Naming Identifier, the name of a Java programming component. Identifier naming rules... Must.
Simple Programs from Chapter 2 Putting the Building Blocks All Together (corresponds with Chapter 2)
Munster Programming Training
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
Chapter 2: Using Data.
Computer Programming TCP1224 Chapter 4 Variables, Constants, and Arithmetic Operators.
CPS120: Introduction to Computer Science
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
1 st Semester Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
Introduction to Programming with RAPTOR
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Code Grammar. Syntax A set of rules that defines the combination of symbols and expressions.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
C++ Basics L KEDIGH. Objectives 1. basic components of a c++ program using proper terminology and programming conventions adopted for this class. 2. List.
Java Expressions MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation ©Akhilesh.
C++ Basics L KEDIGH. Objectives 1. basic components of a c++ program using proper terminology and programming conventions adopted for this class. 2. List.
CSC 107 – Programming For Science. Today’s Goal  Discuss writing functions that return values  return statement’s meaning and how it works  When and.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
The Basics Input / Output, and Primitive Data Types.
CPS120: Introduction to Computer Science Variables and Constants.
A Sample Program public class Hello { public static void main(String[] args) { System.out.println( " Hello, world! " ); }
Introduction to Programming Python Lab 3: Arithmetic 22 January PythonLab3 lecture slides.ppt Ping Brennan
Introduction to Programming
Lecture 5 Computer programming -1-. Input \ Output statement 1- Input (cin) : Use to input data from keyboard. Example : cin >> age; 2- Output (cout):
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
1 st Semester Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
A Sample Program #include using namespace std; int main(void) { cout
Chapter 4 Chapter 4: Variables, Constants, and Arithmetic Operators.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
CS0004: Introduction to Programming
Introduction to Programming
Bill Tucker Austin Community College COSC 1315
Introduction to Programming
A variable is a name for a value stored in memory.
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Chapter 6 JavaScript: Introduction to Scripting
Data Types, Identifiers, and Expressions
JavaScript.
Variables ICS2O.
Unit-1 Introduction to Java
Chapter 2 Variables.
Core Objects, Variables, Input, and Output
Chapter 2: Introduction to C++.
An Introduction to Programming with C++ Fifth Edition
Unit 3: Variables in Java
Chap 2. Identifiers, Keywords, and Types
Module 2 Variables, Data Types and Arithmetic
Variables and Constants
Presentation transcript:

GTECH 731 Lab Session 3 Lab 2 Review, Lab 3 Intro 9/20/10 Lab 2 Review Lab 3 Overview

Lab 2 – Review Introduced to variables Key part of geographic modeling because they hold the current “state” of object being modeled Traffic model of vehicles moving through space Current X, Y coordinates, direction, speed, odometer and fuel Dynamic modeling requires change of “current state” of objects Moving vehicle Current X, Y coordinates would constantly be recalculated Assigning new values to variables based on meaningful calculations X = X + DeltaX Y = Y + DeltaY DeltaX = XVector(Direction, Speed) DeltaY = YVector(Direction, Speed) Speed = SpeedLimit + CongestionFactor + DriverFactor(SpeedLimit) Fuel = Fuel – (MilesTraveled (Odometer)* MPG) X Y DeltaX DeltaY a b

Lab 2 – Review Console program variables declared and initialized (also used in Windows Form) int i = 25;// declaration and initialization in one line Windows Form program variables set in “Properties” window Entered values in Properties window for an object Object name: “lblEquals” Text: “Equals: ” These values are initialized in the “InitializeComponent();” section of code Can override initial value with new assignments i = 25;//assign value via literal i = x;//assign value via other variable i = 2 + 2; //assign value via expression i = Convert.ToInt32(“25”); //assign value via function

Lab 2 – Review Naming conventions: no steadfast rules but consistency is key Member Variables should be nouns iFeet //integer variable for units in “feet” lblOutput.text//label holding the output results Methods should be verbs in Pascal notation btnMilesConversion_Click //button method converting from feet to miles btnMetersConversion_Click //button method converting from feet to meters Notation: “Camel” for variables Start with lowercase letter and init-cap words that make-up variable name Can start with lower case letter of the variable type as in “Hungarian” notation int iMyInteger string sMyString float fMyFloatingPoint Book talks about constants in Pascal notation (init cap) but website talks about constants as all uppercase with words separated by underscore

Lab 3 – Working with Functions Last lab Wrote simple in-line code in console to convert from feet to meters In Windows Form, we used similar code in multiple methods to convert from feet to several different units of measure Typing same or similar code over and over... Can be time consuming in larger programs Is problematic when changes to code are needed later (need to edit multiple locations) Functions provide means to write code in one place that can be called from many places when needed Functions are self-contained blocks of code that perform a given task Should be simple enough to test and know it is working properly Want function to be as generic as possible

Lab 3 – Working with Functions Functions usually perform a single, easily-identified task. Key questions about any function are: What should its name be? Action verb or statement describing what the function does. What are the parameters? Input values function acts upon. What is the return type? Does it return a number a text string or a boolean type? How does it work? What are the steps needed to accomplish the task? public int AddTwoNumbers(int a, int b) { return a+b; } public bool NumbersAreEqual(int a, int b) { if (a == b) { return True; } else { return False; } if NumbersAreEqual(x, y) { z = AddTwoNumbers(x, y); }

Lab 3 – Working with Functions Overview of Lab 3 – Console Using Debug tools to find and solve problems F11 Step into code Breakpoints Locals (variables) window Mouse-over variables and mathematical operators Overview of Lab 3 – Windows Form