1 / 17

Welcome to Hdip 001 Introduction to Programming

Welcome to Hdip 001 Introduction to Programming. Lecturer: Fintan Costello. Where you are. Hdip 001 Programming lectures: Tues 11-12 B1.0 8 Wed 2-3 B1.0 9 Thurs 11-12 B1.0 9 Hdip 001 programming practicals: Thursday 2-4 in the computer lab (block C in science building)

becka
Download Presentation

Welcome to Hdip 001 Introduction to Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Where you are • 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)

  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 4th 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 • Write programs to process information in various ways • Write programs to respond to different situations. You will also develop a useful attitude towards computers • Not to be afraid when things go wrong, but to debug • To try things on your computer and learn from your mistakes • To solve problems in a clear, unambiguous and precise way.

  5. Hdip D001 programming: what you do 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%)

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

  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… Natural languages are forgiving: if you have wrong the grammar, pronounciation, or speling, people can still understanding you be. Programming languages: C, perl, Java... 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 programWelcome.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: Public 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"); } } classis a word that identifies something as a program in java publicis a modifier which identifies something as publicly accessible (other programs can “call” it, which means run it) mainidentifies the main part of a program (the bit that does most of the work). We’ll explain static and void later.

  15. This block identifies everything that is in the public class Welcome This block identifies everything that is in the main part of the class. Blocks {......} A block is a sequence of code between matching curly brackets // 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 output 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.

More Related