Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecturer: Fintan Costello Welcome to Hdip 001 Introduction to Programming.

Similar presentations


Presentation on theme: "Lecturer: Fintan Costello Welcome to Hdip 001 Introduction to Programming."— Presentation transcript:

1 Lecturer: Fintan Costello Welcome to Hdip 001 Introduction to Programming

2  Hdip 001 Programming lectures:  Tues 11-12 B1.08  Wed 2-3 B1.09  Thurs 11-12 B1.09 Hdip 001 programming practicals:  Thursday 2-4 in the computer lab (block C in science building)  Practicals will start next week (Thursday 22nd) Where you are

3 Resources for the programming course Textbook: Introduction to JAVA Programming, Y. Daniel Liang. Prentice Hall, 4th ed. Campus bookstore. We’ll be using this textbook a lot: you should get it. Make sure you get the 4 th edition! Web site: http://inismor.ucd.ie/~fintanc/dip001 Look here to find these slides, course rules and instructions, exam info, practicals, and so on.

4 What will you learn on this course? How to make a computer do what you want: Write programs to quickly solve complex problems You will also develop a useful attitude towards computers Not to be afraid when things go wrong, but to debug Write programs to process information in various ways Write programs to respond to different situations. To try things on your computer and learn from your mistakes To solve problems in a clear, unambiguous and precise way.

5 In this course you will be learning how to program in a computer language called Java. You must Attend programming lectures three times weekly Attend practicals once weekly (1 * 2 hours) Textbook is required reading Marks are based on practical work (30%), plus an exam at the end of term (70%) Hdip D001 programming: what you do

6 Programs and algorithms: some terms A program is a series of instructions or commands to a computer Running a program == carrying out the instructions A well written program implements an algorithm which solves a problem An algorithm is a precise description of how to solve a problem

7 Algorithm for making tea boil water; put teabag into cup; pour water into cup until full; wait 3 minutes; remove teabag; if (want milk){ put milk into cup; } if (want sugar){ put sugar into cup; } stir;

8 Algorithms An ALGORITHM is: 1. Unambiguous 2. Executable 3. Terminating

9 Problem: open a door Algorithm: read sign on door; if (sign says "pull") { pull the door open; } else { push the door open; } Will this work for all doors?

10 Problem: Say hello to someone Algorithm: Ask the person’s name; Remember their name: NAME  their name; Say(“Hello “ + NAME);

11 Programming languages Natural languages: French, English, Swahili… Programming languages: C, perl, Java... Natural languages are forgiving: if you have wrong the grammar, pronounciation, or speling, people can still understanding you be. Computers are not as smart as people: if you don’t have your program’s grammar and spelling exactly right, the computer will not understand and will give an error

12 Your first java program Welcome.java (L, p. 15) // Welcome.java: this application prints // a welcome message public class Welcome { public static void main(String[] args) { System.out.println("Welcome to Java"); }

13 Reseved words // Welcome.java: this program prints // a welcome message public class Welcome { public static void main(String[] args) { System.out.println("Welcome to Java"); } The words in bold are reserved words: they mean something special in the java programming language. Reserved words are case-sensitive: P ublic is wrong.

14 What do these words mean? // Welcome.java: this program prints // a welcome message public class Welcome { public static void main(String[] args) { System.out.println("Welcome to Java"); } class is a word that identifies something as a program in java public is a modifier which identifies something as publicly accessible (other programs can “call” it, which means run it) main identifies the main part of a program (the bit that does most of the work). We’ll explain static and void later.

15 Blocks {......} A block is a sequence of code between matching curly brackets This block identifies everything that is in the public class Welcome This block identifies everything that is in the main part of the class. // Welcome.java: this program prints // a welcome message public class Welcome { public static void main(String[] args) { System.out.println("Welcome to Java"); }

16 Statements A statement is an action. A statement ends with a semi-colon ; System.out.println("Welcome..."); println means ‘print this on a line of its own’ (you can also use print, which doesn’t start a new line). System.out means that println is an action carried out by the out put part of a set of Java programs which you can use to interact with your computer’s System. We’ll learn more about this later when we talk about methods

17 Comments in Java Comments are simply notes for the programmer to remind themseleves and other programmers what a program is meant to do. Comments can contain any text you like // this is a one line comment // and here is another /* this comment can extend over several lines....... */ Comments are not java commands. Always comment your programs! It helps you remember what’s going on.


Download ppt "Lecturer: Fintan Costello Welcome to Hdip 001 Introduction to Programming."

Similar presentations


Ads by Google