Jens Dalsgaard Nielsen Jan Dimon Bendtsen Dept. of Electronic Systems Basic Programming INS-basis GF, PDP and HST.

Slides:



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

INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
Chapter 2: Using Objects Part 1. To learn about variables To understand the concepts of classes and objects To be able to call methods To learn about.
Dale Roberts Introduction to Java - First Program Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
 2005 Pearson Education, Inc. All rights reserved Introduction.
Chapter 1: Introduction
Chapter 1 These slides for CSE 110 Sections are based in part on the textbook-authors’ slides, which are copyright by the authors. The authors state that.
The Java Programming Language  Simple – but abstract  Safe  Platform-independent ("write once, run anywhere")  Has a Rich growing library  Designed.
Shlomo Hershkop1 Introduction to java Class 1 Fall 2003 Shlomo Hershkop.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
Chapter 2 Using Objects. These slides for CSE 110 Sections are based in part on the textbook-authors ’ slides, which are copyright 2003 by Cay Horstmann.
CHAPTER 1 INTRODUCTION GOALS  To understand the activity of programming  To learn about the architecture of computers  To learn about machine code and.
Getting Started with Java
Datalogi A 2: 15/9. Java Slides based on Horstmann chapter 2&3 Objects and classes Import, methods, references Implementing a class.
Java An introduction. Example 1 public class Example1 { public static void main (String [] args) { System.out.println (“This is the first example”); int.
How Create a C++ Program. #include using namespace std; void main() { cout
Computer Science A 2: 6/2. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated.
Chapter 2  Using Objects 1 Chapter 2 Using Objects.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
Computer Science A 1: 3/2. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated.
Chapter 2 types, variables, methods Pages Horstmann.
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
Chapter 1 - Introduction. Ch 1Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
Week 1 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
CS 106 Introduction to Computer Science I 01 / 25 / 2010 Instructor: Michael Eckmann.
Big Java by Cay Horstmann Copyright © 2008 by John Wiley & Sons. All rights reserved. Chapter One: Introduction.
Week 1 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 1 Chapter 1 Introduction.
© 2006 Pearson Education 1 Obj: cont 1.3 and 1.4, to become familiar with identifiers and to understand how programming languages work HW: p.51 #1.8 –
Chapter 1 CSIS-120: Java Intro. What is Programming?  A: It is what makes computer so useful.  The flexibility of a computer is amazing  Write a term.
The Java Programming Language
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Programming Concept Chapter I Introduction to Java Programming.
Big Java by Cay Horstmann Copyright © 2008 by John Wiley & Sons. All rights reserved. Chapter One: Introduction.
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. Chapter 1 – Introduction ( ปรับปรุง )
Chapter 2: Java Fundamentals
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To understand the activity of programming To learn about the architecture.
Fall 2006Slides adapted from Java Concepts companion slides1 Introduction Advanced Programming ICOM 4015 Lecture 1 Reading: Java Concepts Chapter 1.
Chapter 2 Using Objects. Chapter Goals To learn about variables To understand the concepts of classes and objects To be able to call methods To be able.
FIRST JAVA PROGRAM. JAVA PROGRAMS Every program may consist of 1 or more classes. Syntax of a class: Each class can contain 1 or more methods. public.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Introduction to programming in the Java programming language.
Week 2 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Chapter 2 Using Objects. Types A type defines a set of values and the operations that can be carried out on the values Examples: 13 has type int "Hello,
Jens Dalsgaard Nielsen Jan Dimon Bendtsen Dept. of Electronic Systems Basic Programming INS-basis GF, PDP and HST.
1 Principles of Computer Science I Prof. Nadeem Abdul Hamid CSC 120 – Fall 2005 Lecture Unit 2 - Using Objects.
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
Chapter 1 Introduction. Chapter Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To learn about the architecture of computers To learn about machine code.
Chapter 2 Using Objects. Chapter Goals To learn about variables To understand the concepts of classes and objects To be able to call methods To be able.
Agenda Comments Identifiers Keywords Syntax and Symentics Indentation Variables Datatype Operator.
Chapter 1 - Introduction. Announcements Info Sheet Web Site: Lab Hours NotecardsPictures.
CS001 Introduction to Programming Day 6 Sujana Jyothi
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
UFCFY5-30-1Multimedia Studio Coding for Interactive Media Fundamental Concepts.
A Simple Object Oriented Program public class Simple { public static void main (String [] args) { System.out.println(“howdy”); } System.out is an object.
Introduction to programming in java
John Woodward A Simple Program – Hello world
GC101 Introduction to computer and program
Java programming lecture one
Introduction to Programming in Java
Introduction to the C Language
Chapter 2 Using Objects.
First Python Program Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An.
Instructor: Alexander Stoytchev
Presentation transcript:

Jens Dalsgaard Nielsen Jan Dimon Bendtsen Dept. of Electronic Systems Basic Programming INS-basis GF, PDP and HST

Course Goals To understand the activity of programming To become familiar with computing environments, compilers etc. To be able to program, compile and run Java programs To be able to recognize (and fix) syntax and logic errors To be able to use computer programs as an engineering tool

Prerequisites Computer savvy (file management, text editing) Problem solving skills Time management High school math (algebra, trigonometry) No prior programming background required

Course Organization Introduction to the course, getting started Tools, getting operational Classes and objects Program control Basic GUI programming Data structures File I/O Slightly less basic GUI programming 1)+10) Mini-project

Examination “Mini-project” - at the end of the course, you write a program that:  Satisfies a “requirement specification” posed by the lecturers  Demonstrates that you know how to program in Java  Demonstrates that you are able to use an Integrated Development Environment (Eclipse) Individual examination (but it is OK to do the actual work in small groups)‏

Chapter 1 Introduction to Java Programming

What Is Programming? Computers are programmed to perform tasks Different tasks = different programs Program  Sequence of basic operations executed in succession  Contains instruction sequences for all tasks it can execute Sophisticated programs require teams of highly skilled programmers and other professionals

Schematic Diagram of a Computer Figure 5: Schematic Diagram of a Computer

The Java Programming Language Simple Safe Platform-independent ("write once, run anywhere") Rich library (packages) Designed for the internet

An Integrated Development Environment Figure 9: An Integrated Development Environment

File HelloTester.java 1: public class HelloTester 2: { 3: public static void main(String[] args) 4: { 5: // Display a greeting in the console window 6: 7: System.out.println("Hello, World!"); 8: } 9: } Output Hello, World!

HelloTester in an IDE Figure 12: Running the HelloTester Program in an Integrated Development Environment

A Simple Program Figure 13: Calling a Method System Class System.out Object println Method public class ClassName public static void main(String[] args) // comment Method call

Syntax 1.1: Method Call object.methodName(parameters)‏ Example: System.out.println("Hello, Dave!"); Purpose: To invoke a method of an object and supply any additional parameters

Errors Syntax errors Detected by the compiler Logic errors Detected (hopefully) through testing System.ouch.print("..."); System.out.print("Hello); System.out.print("Hell");

The Compilation Process Figure 14: From Source Code to Running Program

Chapter 2 Using Objects

Types and Variables Every value has a type Variable declaration examples: Variables  Store values  Can be used in place of the objects they store String greeting = "Hello, World!"; PrintStream printer = System.out; int luckyNumber = 13;

Types and Variables Every value has a type Variable declaration examples: Variables  Store values  Can be used in place of the objects they store String greeting = "Hello, World!"; PrintStream printer = System.out; int luckyNumber = 13;

Syntax 2.1: Variable Definition typeName variableName = value; or typeName variableName; Example: String greeting = "Hello, Dave!"; Purpose: To define a new variable of a particular type and optionally supply an initial value

Identifiers Identifier: name of a variable, method, or class Rules for identifiers in Java:  Can be made up of letters, digits, and the underscore (_) character  Cannot start with a digit  Cannot use other symbols such as ? or %  Spaces are not permitted inside identifiers  You cannot use reserved words  They are case sensitive Continued…

The Assignment Operator Assignment operator: = Not used as a statement about equality Used to change the value of a variable int luckyNumber = 13; luckyNumber = 12; Figure 1: Assigning a New Value to a Variable

Uninitialized Variables Error: Figure 2: An Uninitialized Object Variable int luckyNumber; System.out.println(luckyNumber); // ERROR - uninitialized variable

Syntax 2.2: Assignment variableName = value; Example: luckyNumber = 12; Purpose: To assign a new value to a previously defined variable.

Summary  Main goal: Programming as an Engineering tool  Examination: Mini-project  Organization: Short(?) lectures and plenty of programming at the PC  Programming exercises are carried out in Eclipse  “Hello World”  Variables are used for storing values, via assignment; they are referred to using identifiers (names)‏