CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction

Size: px
Start display at page:

Download "CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction"

Transcription

1 CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics COMP-202 Unit 1: Introduction

2 Announcements Did you miss the first lecture? Come talk to me after class. If you want an exemption from this course, please send me

3 Assignment 0 Assignment 0 is posted. Due Wednesday January 12th. Worth 2% The assignment is geared towards making sure you have everything set up properly and some basic programming. After today's class, you will have most of the knowledge you need to do the assignment. (A bit may be done on Monday)

4 Last Class Administrative stuff Modular programming A tiny bit about java

5 Today Understanding Input/Output How to count cards! How computers think A tiny bit more about java

6 After today, you should be able to... Understand the input/output of a problem, function, or method Explain the way we go from a problem to a computer program, and understand why it is useful to break problems into subproblems Know in English what a loop variable and if statement mean Be able to write output to the screen in Java Understand the idea of methods in Java

7 You should be able to answer questions like... What is the input and output of the function f(x)=sin(x)? What would a variable be used for? What is an example of the use of {,, and ; in java. What is the input and output of a method that looks like public static double MyMethod(int x, double y)

8 Part 1: What Is Programming?

9 Programming and Computers In order to understand what programming is, we need to know what a computer is A computer is a machine that executes lists of instructions We feed a list of instructions to the computer and the computer executes them The computer may apply the instructions on additional information fed to the computer (the input) The computer may produce information as a result of executing this list of instructions (the output) COMP Introduction 9

10 Programming and Computers Programming a computer involves two things: 1) Designing lists of instructions that will make the computer solve specific problems 2) Having the computer execute the instructions The purpose is to have the computer solve the problem for you instead of you solving the problem by hand COMP Introduction 10

11 Designing instruction list Designing an instruction list is largely about breaking problems down into smaller tasks. It is also about considering the input and output of a program COMP Introduction 11

12 Input vs Output : Input The input to a program is what goes into it. It is whatever is given to the program or problem. This is anything that is necessary to solve it. COMP Introduction 12

13 Input vs Output : Output The output from a program is what comes from it. This is anything that is produced as a result of the program running COMP Introduction 13

14 Example: f(x) = 2x The input to this mathematical function is a number The output to this function is a number Note: Input is similar to domain in math. Output is similar to range We have to judge by context whether this function is being used on integers, real numbers, or imaginary numbers. (Or something completely different!) In Java, we will explicitly write what the domain and range are. COMP Introduction 14

15 Example: f(x,y) = 2x + 3y What is the input and output? COMP Introduction 15

16 Example: f(x,y) = 2x + 3y The input to this mathematical function is two numbers -- x and y The output is 1 number. The sum of 2x and 3y COMP Introduction 16

17 Input/Output Input/Output is not necessarily restricted to math problems. For example, what is the input and output of the problem cooking scrambled eggs COMP Introduction 17

18 Cooking Scrambled Eggs (1) Input (things we need to follow the instructions): Two eggs A tablespoon of oil A pan A stove Output (things that result from following the instructions): Scrambled eggs COMP Introduction 18

19 Cooking Scrambled Eggs (2) Instructions: Add oil to pan Heat pan on stove Crack eggs into pan Mix until light and flaky COMP Introduction 19

20 Mmmmm... COMP Introduction 20

21 How to count cards! COMP Introduction 21

22 Counting Cards of a Given Suit Input: The deck The suit we are looking for COMP Introduction 22

23 Breaking the problem down How can we write this suit-counting problem down in simple to understand instructions? COMP Introduction 23

24 Counting Cards of a Given Suit 1)Take a blank piece of paper and the deck 2)If there are cards left, take the top card in the deck If there are not cards left, skip to step 2 3)Check if the card belongs to the suit you are looking for. If so, make a mark on the piece of paper. 4)Go back to step 2 5)Count the number of marks on your paper. That number is the answer we want. By the way, they will not let you do this at the casino! COMP Introduction 24

25 Counting Cards of a Given Suit 1)Take a blank piece of paper and the deck 2)If there are cards left, take the top card in the deck If there are not cards left, skip to step 2 3)Check if the card belongs to the suit you are looking for. If so, make a mark on the piece of paper. 4)Go back to step 2 5)Count the number of marks on your paper. That number is the answer we want. an if statement COMP Introduction 25

26 Counting Cards of a Given Suit 1)Take a blank piece of paper and the deck 2)If there are cards left, take the top card in the deck If there are not cards left, skip to step 2 3)Check if the card belongs to the suit you are looking for. If so, make a mark on the piece of paper. 4)Go back to step 2 5)Count the number of marks on your paper. That number is the answer we want. an if statement a loop COMP Introduction 26

27 Counting Cards of a Given Suit 1)Take a blank piece of paper and the deck 2)If there are cards left, take the top card in the deck If there are not cards left, skip to step 2 3)Check if the card belongs to the suit you are looking for. If so, make a mark on the piece of paper. 4)Go back to step 2 5)Count the number of marks on your paper. That number is the answer we want. an if statement a variable (it stores something) a loop COMP Introduction 27

28 Exercise:Determine Whether you have an even/odd # of pages of paper Suppose that your computer is a person who does not know how to multiply/divide/add/subtract and does not know what odd or even mean. Write down instructions for determining whether a stack of paper has an even or odd number of sheets. What is the input and output? Hint: You may find an additional 2-sided, such as a coin or another piece of paper useful. COMP Introduction 28

29 Amelia Bedilia COMP Introduction 29

30 Instructions and Precision The instructions for finding a card in a deck or counting the number of cards of a given suit in a deck are very precise and unambiguous Amelia would have no room for misunderstanding Writing lists of instructions like these is the very essence of programming a computer COMP Introduction 30

31 Programs (1) A computer program is essentially a list of instructions telling a computer what to do The computer is stupid in that it is just following the instructions without knowing what it is doing. Thus you must be very precise and omit no details. COMP Introduction 31

32 Programs (1) Programs have an input and an output as well. If you omit the proper instructions or include the wrong instructions, generally 4 things can happen: 1)You get incredibly lucky and on that particular input it works anyway 2)The program gives the incorrect output 3)The program crashes 4)The program goes on forever and ever COMP Introduction 32

33 Case 1 Sometimes you will give the computer the wrong instructions, but it will work anyway on a particular input. For example, in the card program, suppose we omitted the instruction make a mark on the piece of paper This means the count will always be 0, no matter what the input. When would this still lead to the right answer? COMP Introduction 33

34 Case 2 The program gives the wrong output This would happen in the previous example on any input where the pack of cards had at least one card of the suit in question. COMP Introduction 34

35 Case 3 Sometimes the program will crash. In the card example, this happens if the computer is unable to do a certain step. For example, at step 1 we have: Take a blank piece of paper and the deck Suppose you don't have any paper. Then this step is impossible. In a computer program, when something like this happens, the program will crash, exiting without output COMP Introduction 35

36 Case 4 The program goes on forever and ever What if after step 3, we inserted Put the card in your hand back on top of the deck Then the program would go on forever. We would continually pick up the top card, check if it is the suit we are interested in, possibly mark it down on paper, then put it back on top. Then we would pick up the top card (the same card!), check if it is the suit we are interested in, possibly mark it down on paper, then put it back on top. Then we would pick up the top card COMP Introduction 36

37 Case 4 check if it is the suit we are interested in, possibly mark it down on paper, then put it back on top. Then we would pick up the top card, check if it is the suit we are interested in, possibly mark it down on paper, then put it back on top. Then we would pick up the top card, check if it is the suit we are interested in, possibly mark it down on paper, then put it back on top. Then we would pick up the top card, check if it is the suit we are interested in, possibly mark it down on paper, then put it back on top. Then we would pick up the top card, check if it is the suit we are interested in, possibly mark it down on paper, then put it back on top. Then we would pick up the top card, check if it is the suit we are interested in, possibly mark it down on paper, then put it back on top. COMP Introduction 37

38 Having the computer execute the instructions This step consists of translating your human words into a language the computer understands Kind of like learning a foreign language. But there are some key differences. Sentences in human languages can often have many interpretations. COMP Introduction 38

39 Human and Computer Languages Compare to the following English sentence: "The lady hit the man with a baby" Does this mean 1)A lady hit a man who had a baby? (Dude, what a jerk!) 2)A lady used a baby to hit a man? (Good lord!) 3)A lady and a baby ganged up on a man and hit him. (Kids today!) Computer statements, on the other hand, always have only one possible interpretation. COMP Introduction 39

40 Human and Computer Languages One of the challenges is to learn the different interpretations the computer will give to commands. The computer will not normally tell you how it is interpreting things. It is up to you to figure it out, both by looking at your code and observing the output. COMP Introduction 40

41 Complex Tasks Sometimes, we want the computer to perform complex tasks Writing a detailed list of precise instructions for this complex task would be very difficult There are just too many instructions for humans to manage Solution: Break down the complex task into a series of simpler tasks; if the simpler tasks are still too complex, break them down into even simpler tasks Write a list of instructions for each of the simpler tasks The list of instructions for each of the simpler tasks can be used as a single instruction in the list of instructions that performs the original task COMP Introduction 41

42 Summary so far What are some of the things we know we have to do to solve a problem on a computer? COMP Introduction 42

43 Summary so far 1)Figure out the input and output of the problem 2)Write a very precise set of instructions for solving the problem. 3)Translate each instruction from human language to a computer language. If we have broken our steps in number two into very small pieces, then number three will be much easier. COMP Introduction 43

44 Summary so far Thinking about the card problem, what are some things that we would like the computer to be able to do? COMP Introduction 44

45 Summary so far 1)Store information (i.e. the piece of paper) 2)Output information (i.e. the final count) 3)Check if certain conditions are satisfied or not (i.e. does the card match and check if there remain any cards ) 4)Have a way to jump to step n when we want to (i.e. go back to step 2 5)Be able to make subproblems or subtasks One more thing is the program needs to know where to start! COMP Introduction 45

46 Java Program: Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); The first thing is that every program in java MUST be inside of a class. For now, do not worry about precisely what that means and just make sure that every program has the line public class NAMEOFFILE { in it. (Note: we'll see later that this isn't always on the first line though!) COMP Introduction 46

47 Java Program: Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); The red { marks the beginning of the class HelloWorld. {'s always mark the beginning of a block (or segment) of code. Each { always has a corresponding to mark the end. You can tell which corresponds to which because the first { opened, will correspond with the last COMP Introduction 47

48 Java Program: Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); Which matches with the red {, and which would match with the blue {? COMP Introduction 48

49 Java Program: Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); Try at home: What happens if you remove the final, so that there are not matching braces? What happens if you add an extra at the end so that there are 3 s? COMP Introduction 49

50 Java Program: Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); The next thing to notice is on the second line. This is known as the main method. The important thing to know is that the main method is where your program starts. (We will later see exactly what all the words before mean) COMP Introduction 50

51 Java Program: Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); Without the highlighted line (or something very similar), the computer will not know where to start. It is possible to have a class that does not have a main method. However, then you can not run it as a program. We will see examples of this later. COMP Introduction 51

52 Returning to our list 1)Store information (i.e. the piece of paper) 2)Output information (i.e. the final count) 3)Check if certain conditions are satisfied or not (i.e. does the card match and check if there remain any cards ) 4)Have a way to jump to step n when we want to (i.e. go back to step 2 5)Be able to make subproblems or subtasks One more thing is the program needs to know where to start! COMP Introduction 52

53 Java Program: Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); The highlighted line is one of the ways you can output information in java. Anything between the quotations will be printed to the screen. The entire line is called a statement Note: The computer expects everything between the quotations to all be on one line. COMP Introduction 53

54 Java Program: Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); The computer expects everything between the quotations will all be one one line. If you want to write multiple lines, you could write multiple statements. COMP Introduction 54

55 Java Program: Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); System.out.println( I am on a second line ); Exercise to think about: What if we want to write a quotation mark to the screen? Hint: google string escape sequence or something similar COMP Introduction 55

56 Java Program: Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); Every statement in java must end in a semicolon. Next week we will go into more detail on what exactly a statement is. COMP Introduction 56

57 Methods A method is like a sub-program or sub-routine. You can use it as part of your program. When you call a method, the computer will jump from the place it was before to the method. When it finishes the method, it will jump back. COMP Introduction 57

58 Using a method or subroutine public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); PrintMoreStuff(); System.out.println( Goodbye world! ); //the next line is a method public static void PrintMoreStuff() { System.out.println( More stuff here ); What is the order of steps here? COMP Introduction 58

59 Using a method or subroutine public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); PrintMoreStuff(); System.out.println( Goodbye world! ); //the next line is a method public static void PrintMoreStuff() { System.out.println( More stuff here ); 1)First the program starts at main COMP Introduction 59

60 Using a method or subroutine public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); PrintMoreStuff(); System.out.println( Goodbye world! ); //the next line is a method public static void PrintMoreStuff() { System.out.println( More stuff here ); 2)Next the program prints HelloWorld COMP Introduction 60

61 Using a method or subroutine public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); PrintMoreStuff(); System.out.println( Goodbye world! ); //the next line is a method public static void PrintMoreStuff() { System.out.println( More stuff here ); 3)The program calls the method PrintMoreStuff() so it jumps to the section PrintMoreStuff() COMP Introduction 61

62 Using a method or subroutine public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); PrintMoreStuff(); System.out.println( Goodbye world! ); //the next line is a method public static void PrintMoreStuff() { System.out.println( More stuff here ); 4)Now the program prints More stuff here COMP Introduction 62

63 Using a method or subroutine public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); PrintMoreStuff(); System.out.println( Goodbye world! ); //the next line is a method public static void PrintMoreStuff() { System.out.println( More stuff here ); 5)It then returns to where the method was called and prints Goodbye world! COMP Introduction 63

64 Comments You may have noticed the following line and thought, That's weird. It looks a lot like English to me //the next line is a method That's because it is a comment. Any time you write two /'s in a row, the rest of the line will be completely ignored by the compiler. It is a good idea to add explanations for code you write. That way either you or someone else looking at your code will understand what it does. If you want to write a longer comments, put the comments between /* which starts the comment and COMP Introduction 64

65 Returning a value Like programs, methods can also take input and give output. Many mathematical functions can be written this way. In the previous example, the method gives as output void (i.e. nothing) We know this because the first line of the method is: public static void PrintMoreStuff() COMP Introduction 65

66 Returning a value Methods can also give output. If you want the method to give an output, you write what you want it to output instead of the word void. For example public static Flamingo PrintMoreStuff() --if you want the method to output flamingos public static Pizza PrintMoreStuff() --if you want it to output pizza COMP Introduction 66

67 int, string,double A computer does not know what Flamingos or Pizza are unless you define them. However there are a few things a computer knows already. A few (but not all) of these are: int -- an integer (3,4,-10) string a sequence of letters, numbers, punctuation, etc ( hello,, foo ) double a real number (2.6,-55,0) public static int PrintMoreStuff() --if you want the method to output an int COMP Introduction 67

68 Outputting a value If you make your method output something instead of void, you can write what it should output using a return statement. We often call this returning a value /*The following function ReturnsANumber*/ public static int ReturnANumber() { return 0; This means the method outputs 0. COMP Introduction 68

69 Getting the output If you know a method has output, you use it by calling the method public class GetANumber { public static void main(string[] args) { System.out.println(ReturnANumber()); public static int ReturnANumber() { return 0 There is a syntax error here. What is it? COMP Introduction 69

70 Storing the output If you want to store a value, you can do what is known as declaring a variable. To do this, first write the kind or type of variable you want to store. This could be an int, double, string, or other things. This MUST match the type you are trying to store. For example, if I am trying to store the output from ReturnANumber(), I should put it into an int COMP Introduction 70

71 Storing the output Somewhere in your code, you could have: int x = ReturnANumber(); System.out.println(x); The first line does a lot of things. First it calls the method ReturnANumber(). It then stores the output from ReturnANumber() into the variable x. Because ReturnANumber() outputs or returns an int, we make x an int. The second line, takes the stored value and prints it to COMP Introduction 71

72 Giving Input to Methods Methods can also have input Everything between the ()'s in the method is input to the method. public static int ReturnANumber() { return 0; There is nothing between the (), so the method has no input. This is why it always outputs the same thing COMP Introduction 72

73 Giving Input to Methods public static int AddOne(int x) { x+1; This method takes as input one value. This value must be an int. We often refer to the input a method takes as the method's arguments What do you think this method does? COMP Introduction 73

74 Calling a method with arguments The previous method takes as input one int and outputs one int. If you try to call it without giving it an int, it won't know what to do. When you call it, you must give it an int, for example: System.out.println(AddOne(3)); will work but System.out.println(AddOne()); will not COMP Introduction 74

75 Methods with more than one argument Methods can also have more than one argument as input. For example public static int Add(int x, int y) { return????? What could we write instead of????? if we wanted the method to output the addition of x and y? COMP Introduction 75

76 Example: Experimenting with things Suppose we want to understand the order of operations in Java. We try googling it but have some trouble understanding the explanations. How could we try to figure it out? Well one way to do it is letting Java tell you. For example, write the line: System.out.println(3+4*3); Then look at the output. If it is 21, then it probably adds first. If it is 15, then it probably multiplies first. COMP Introduction 76

77 Exercises 1)Make sure you can compile HelloWorld.java 2)Take the program from the slides with the method PrintMoreStuff() in it. Make sure you can compile it 3)Try to change the method PrintMoreStuff so that it takes as a method an int and prints the value of the int instead of always printing the same thing. 4)Call this method 5 times from your main() method. Make sure one time is with the value stored in a variable 5)Now change PrintMoreStuff() so that it takes two ints as input and prints the sum of the 2 values COMP Introduction 77

78 Next Class How computers store all these values What memory in a computer is More on methods and variables COMP Introduction 78

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics COMP-202 Unit 1: Introduction Assignment 1 Assignment 1 posted on WebCt and course website. It is due September 22nd

More information

COMP-202 Unit 1: Introduction. CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics

COMP-202 Unit 1: Introduction. CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics COMP-202 Unit 1: Introduction CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics Last Class Solving many little problems to avoid thinking about too much at once! A tiny

More information

COMP-202 Unit 1: Introduction. CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics

COMP-202 Unit 1: Introduction. CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics COMP-202 Unit 1: Introduction CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics Last Class Solving many little problems to avoid thinking about too much at once! A tiny

More information

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016 COMP-202: Foundations of Programming Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016 Learn about cutting-edge research over lunch with cool profs January 18-22, 2015 11:30

More information

COMP-202 Unit 2: Java Basics. CONTENTS: Using Expressions and Variables Types Strings Methods

COMP-202 Unit 2: Java Basics. CONTENTS: Using Expressions and Variables Types Strings Methods COMP-202 Unit 2: Java Basics CONTENTS: Using Expressions and Variables Types Strings Methods Assignment 1 Assignment 1 posted on WebCt and course website. It is due May 18th st at 23:30 Worth 6% Part programming,

More information

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2015

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2015 COMP-202: Foundations of Programming Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2015 Assignment Due Date Assignment 1 is now due on Tuesday, Jan 20 th, 11:59pm. Quiz 1 is

More information

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to A PROGRAM IS A SEQUENCE of instructions that a computer can execute to perform some task. A simple enough idea, but for the computer to make any use of the instructions, they must be written in a form

More information

COMP 102: Computers and Computing

COMP 102: Computers and Computing COMP 102: Computers and Computing Lecture 5: What is Programming? Instructor: Kaleem Siddiqi (siddiqi@cim.mcgill.ca) Class web page: www.cim.mcgill.ca/~siddiqi/102.html Motivation The advantage of a computer

More information

Java Programming Fundamentals - Day Instructor: Jason Yoon Website:

Java Programming Fundamentals - Day Instructor: Jason Yoon Website: Java Programming Fundamentals - Day 1 07.09.2016 Instructor: Jason Yoon Website: http://mryoon.weebly.com Quick Advice Before We Get Started Java is not the same as javascript! Don t get them confused

More information

COMP-202 Unit 0: Course Details

COMP-202 Unit 0: Course Details COMP-202 Unit 0: Course Details CONTENTS: Focus of the Course and Prerequisites Outline and Textbook Course Structure and Grading Scheme Computer Lab Info and Required Software Getting started thinking

More information

Wentworth Institute of Technology. Engineering & Technology WIT COMP1000. Java Basics

Wentworth Institute of Technology. Engineering & Technology WIT COMP1000. Java Basics WIT COMP1000 Java Basics Java Origins Java was developed by James Gosling at Sun Microsystems in the early 1990s It was derived largely from the C++ programming language with several enhancements Java

More information

Get JAVA. I will just tell you what I did (on January 10, 2017). I went to:

Get JAVA. I will just tell you what I did (on January 10, 2017). I went to: Get JAVA To compile programs you need the JDK (Java Development Kit). To RUN programs you need the JRE (Java Runtime Environment). This download will get BOTH of them, so that you will be able to both

More information

CSCI 1103: Introduction

CSCI 1103: Introduction CSCI 1103: Introduction Chris Kauffman Last Updated: Wed Sep 13 10:43:47 CDT 2017 1 Logistics Reading Eck Ch 1 Available online: http://math.hws.edu/javanotes/ Reading ahead is encouraged Goals Basic Model

More information

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet. Mr G s Java Jive #2: Yo! Our First Program With this handout you ll write your first program, which we ll call Yo. Programs, Classes, and Objects, Oh My! People regularly refer to Java as a language that

More information

COMP-202: Foundations of Programming. Lecture 4: Flow Control Loops Sandeep Manjanna, Summer 2015

COMP-202: Foundations of Programming. Lecture 4: Flow Control Loops Sandeep Manjanna, Summer 2015 COMP-202: Foundations of Programming Lecture 4: Flow Control Loops Sandeep Manjanna, Summer 2015 Announcements Check the calendar on the course webpage regularly for updates on tutorials and office hours.

More information

St. Edmund Preparatory High School Brooklyn, NY

St. Edmund Preparatory High School Brooklyn, NY AP Computer Science Mr. A. Pinnavaia Summer Assignment St. Edmund Preparatory High School Name: I know it has been about 7 months since you last thought about programming. It s ok. I wouldn t want to think

More information

Computer Science is...

Computer Science is... Computer Science is... Automated Software Verification Using mathematical logic, computer scientists try to design tools to automatically detect runtime and logical errors in huge, complex programs. Right:

More information

Programming with Java

Programming with Java Programming with Java Variables and Output Statement Lecture 03 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives ü Declare and assign values to variable ü How to use eclipse ü What

More information

CS125 : Introduction to Computer Science. Lecture Notes #4 Type Checking, Input/Output, and Programming Style

CS125 : Introduction to Computer Science. Lecture Notes #4 Type Checking, Input/Output, and Programming Style CS125 : Introduction to Computer Science Lecture Notes #4 Type Checking, Input/Output, and Programming Style c 2005, 2004, 2002, 2001, 2000 Jason Zych 1 Lecture 4 : Type Checking, Input/Output, and Programming

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG 1 Notice Reading Assignment Chapter 1: Introduction to Java Programming Homework 1 It is due this coming Sunday

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #43. Multidimensional Arrays

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #43. Multidimensional Arrays Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #43 Multidimensional Arrays In this video will look at multi-dimensional arrays. (Refer Slide Time: 00:03) In

More information

Lab # 2. For today s lab:

Lab # 2. For today s lab: 1 ITI 1120 Lab # 2 Contributors: G. Arbez, M. Eid, D. Inkpen, A. Williams, D. Amyot 1 For today s lab: Go the course webpage Follow the links to the lab notes for Lab 2. Save all the java programs you

More information

CMSC 150 LECTURE 1 INTRODUCTION TO COURSE COMPUTER SCIENCE HELLO WORLD

CMSC 150 LECTURE 1 INTRODUCTION TO COURSE COMPUTER SCIENCE HELLO WORLD CMSC 150 INTRODUCTION TO COMPUTING ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH INTRODUCTION TO JAVA PROGRAMMING, LIANG (PEARSON 2014) LECTURE 1 INTRODUCTION TO COURSE COMPUTER SCIENCE

More information

Controls Structure for Repetition

Controls Structure for Repetition Controls Structure for Repetition So far we have looked at the if statement, a control structure that allows us to execute different pieces of code based on certain conditions. However, the true power

More information

Introduction to the course and basic programming concepts

Introduction to the course and basic programming concepts Introduction to the course and basic programming concepts Lecture 1 of TDA 540 Object-Oriented Programming Jesper Cockx Fall 2018 Chalmers University of Technology Gothenburg University About the course

More information

COMP-202 Unit 2: Java Basics. CONTENTS: Printing to the Screen Getting input from the user Types of variables Using Expressions and Variables

COMP-202 Unit 2: Java Basics. CONTENTS: Printing to the Screen Getting input from the user Types of variables Using Expressions and Variables COMP-202 Unit 2: Java Basics CONTENTS: Printing to the Screen Getting input from the user Types of variables Using Expressions and Variables Assignment 1 Assignment 1 posted on WebCt and course website.

More information

COMP-202 Unit 2: Java Basics. CONTENTS: Printing to the Screen Getting input from the user Types of variables Using Expressions and Variables

COMP-202 Unit 2: Java Basics. CONTENTS: Printing to the Screen Getting input from the user Types of variables Using Expressions and Variables COMP-202 Unit 2: Java Basics CONTENTS: Printing to the Screen Getting input from the user Types of variables Using Expressions and Variables Part 1: Printing to the Screen Recall: HelloWorld public class

More information

CS 177 Recitation. Week 1 Intro to Java

CS 177 Recitation. Week 1 Intro to Java CS 177 Recitation Week 1 Intro to Java Questions? Computers Computers can do really complex stuff. How? By manipulating data according to lists of instructions. Fundamentally, this is all that a computer

More information

CS 11 java track: lecture 1

CS 11 java track: lecture 1 CS 11 java track: lecture 1 Administrivia need a CS cluster account http://www.cs.caltech.edu/ cgi-bin/sysadmin/account_request.cgi need to know UNIX www.its.caltech.edu/its/facilities/labsclusters/ unix/unixtutorial.shtml

More information

COMP 202 Java in one week

COMP 202 Java in one week COMP 202 Java in one week... Continued CONTENTS: Return to material from previous lecture At-home programming exercises Please Do Ask Questions It's perfectly normal not to understand everything Most of

More information

COMP-202 Unit 4: Programming with Iterations

COMP-202 Unit 4: Programming with Iterations COMP-202 Unit 4: Programming with Iterations Doing the same thing again and again and again and again and again and again and again and again and again... CONTENTS: While loops Class (static) variables

More information

COMP-202 Unit 2: Java Basics. CONTENTS: Printing to the Screen Getting input from the user Types of variables Using Expressions and Variables

COMP-202 Unit 2: Java Basics. CONTENTS: Printing to the Screen Getting input from the user Types of variables Using Expressions and Variables COMP-202 Unit 2: Java Basics CONTENTS: Printing to the Screen Getting input from the user Types of variables Using Expressions and Variables Part 1: Printing to the Screen Recall: HelloWorld public class

More information

Java Programming. What is a program? Programs Recipes. Programs as Recipes 8/16/12. Pancakes In one bowl. mix: 1½ cup flour

Java Programming. What is a program? Programs Recipes. Programs as Recipes 8/16/12. Pancakes In one bowl. mix: 1½ cup flour What is a program? Java Programming CS 160, Fall Semester 2012 TOPICS Computer Programs Using Eclipse Program Program Components Definition: a sequence of instructions telling a computer what to do Analogy:

More information

How to approach a computational problem

How to approach a computational problem How to approach a computational problem A lot of people find computer programming difficult, especially when they first get started with it. Sometimes the problems are problems specifically related to

More information

COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette

COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette COMP 250: Java Programming I Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette Variables and types [Downey Ch 2] Variable: temporary storage location in memory.

More information

CONTENTS: While loops Class (static) variables and constants Top Down Programming For loops Nested Loops

CONTENTS: While loops Class (static) variables and constants Top Down Programming For loops Nested Loops COMP-202 Unit 4: Programming with Iterations Doing the same thing again and again and again and again and again and again and again and again and again... CONTENTS: While loops Class (static) variables

More information

Warmup : Name that tune!

Warmup : Name that tune! Warmup : Name that tune! Write, using a loop, Java code to print the lyrics to the song 99 Bottles of Beer on the Wall 99 bottles of beer on the wall. 99 bottles of beer. Take one down, pass it around,

More information

Math Modeling in Java: An S-I Compartment Model

Math Modeling in Java: An S-I Compartment Model 1 Math Modeling in Java: An S-I Compartment Model Basic Concepts What is a compartment model? A compartment model is one in which a population is modeled by treating its members as if they are separated

More information

School of Computer Science CPS109 Course Notes 6 Alexander Ferworn Updated Fall 15. CPS109 Course Notes 6. Alexander Ferworn

School of Computer Science CPS109 Course Notes 6 Alexander Ferworn Updated Fall 15. CPS109 Course Notes 6. Alexander Ferworn CPS109 Course Notes 6 Alexander Ferworn Unrelated Facts Worth Remembering Use metaphors to understand issues and explain them to others. Look up what metaphor means. Table of Contents Contents 1 ITERATION...

More information

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple

More information

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch Purpose: We will take a look at programming this week using a language called Scratch. Scratch is a programming language that was developed

More information

COMP-202: Foundations of Programming. Lecture 3: Boolean, Mathematical Expressions, and Flow Control Sandeep Manjanna, Summer 2015

COMP-202: Foundations of Programming. Lecture 3: Boolean, Mathematical Expressions, and Flow Control Sandeep Manjanna, Summer 2015 COMP-202: Foundations of Programming Lecture 3: Boolean, Mathematical Expressions, and Flow Control Sandeep Manjanna, Summer 2015 Announcements Slides will be posted before the class. There might be few

More information

Post Experiment Interview Questions

Post Experiment Interview Questions Post Experiment Interview Questions Questions about the Maximum Problem 1. What is this problem statement asking? 2. What is meant by positive integers? 3. What does it mean by the user entering valid

More information

Module 10A Lecture - 20 What is a function? Why use functions Example: power (base, n)

Module 10A Lecture - 20 What is a function? Why use functions Example: power (base, n) Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Module 10A Lecture - 20 What is a function?

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG 1 Notice Class Website http://www.cs.umb.edu/~jane/cs114/ Reading Assignment Chapter 1: Introduction to Java Programming

More information

Part II Composition of Functions

Part II Composition of Functions Part II Composition of Functions The big idea in this part of the book is deceptively simple. It s that we can take the value returned by one function and use it as an argument to another function. By

More information

ICOM 4015 Advanced Programming Laboratory. Chapter 1 Introduction to Eclipse, Java and JUnit

ICOM 4015 Advanced Programming Laboratory. Chapter 1 Introduction to Eclipse, Java and JUnit ICOM 4015 Advanced Programming Laboratory Chapter 1 Introduction to Eclipse, Java and JUnit University of Puerto Rico Electrical and Computer Engineering Department by Juan E. Surís 1 Introduction This

More information

Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur

Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur Lecture 04 Demonstration 1 So, we have learned about how to run Java programs

More information

COMP 110 Project 1 Programming Project Warm-Up Exercise

COMP 110 Project 1 Programming Project Warm-Up Exercise COMP 110 Project 1 Programming Project Warm-Up Exercise Creating Java Source Files Over the semester, several text editors will be suggested for students to try out. Initially, I suggest you use JGrasp,

More information

Midterms Save the Dates!

Midterms Save the Dates! University of British Columbia CPSC 111, Intro to Computation Alan J. Hu (Using the Scanner and String Classes) Anatomy of a Java Program Readings This Week s Reading: Ch 3.1-3.8 (Major conceptual jump

More information

CSE 1223: Introduction to Computer Programming in Java Chapter 1 Computer Basics

CSE 1223: Introduction to Computer Programming in Java Chapter 1 Computer Basics CSE 1223: Introduction to Computer Programming in Java Chapter 1 Computer Basics 1 Computer Basics Computer system: hardware + software Hardware: the physical components Software: the instructions that

More information

COMP-202 More Complex OOP

COMP-202 More Complex OOP COMP-202 More Complex OOP Defining your own types: Remember that we can define our own types/classes. These classes are objects and have attributes and behaviors You create an object or an instance of

More information

Software and Programming 1

Software and Programming 1 Software and Programming 1 Lab 1: Introduction, HelloWorld Program and use of the Debugger 17 January 2019 SP1-Lab1-2018-19.pptx Tobi Brodie (tobi@dcs.bbk.ac.uk) 1 Module Information Lectures: Afternoon

More information

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. Today! Build HelloWorld yourself in BlueJ and Eclipse. Look at all the Java keywords. Primitive Types. HelloWorld in BlueJ 1. Find BlueJ in the start menu, but start the Select VM program instead (you

More information

Java Bytecode (binary file)

Java Bytecode (binary file) Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.

More information

Outline. CIS 110: Introduction to Computer Programming. What is Computer Science? What is computer programming? What is computer science?

Outline. CIS 110: Introduction to Computer Programming. What is Computer Science? What is computer programming? What is computer science? Outline CIS 110: Introduction to Computer Programming Lecture 1 An introduction of an introduction ( 1.1 1.3)* 1. What is computer science and computer programming? 2. Introductions and logistics 3. The

More information

Chapter 5 Methods. public class FirstMethod { public static void main(string[] args) { double x= -2.0, y; for (int i = 1; i <= 5; i++ ) { y = f( x );

Chapter 5 Methods. public class FirstMethod { public static void main(string[] args) { double x= -2.0, y; for (int i = 1; i <= 5; i++ ) { y = f( x ); Chapter 5 Methods Sections Pages Review Questions Programming Exercises 5.1 5.11 142 166 1 18 2 22 (evens), 30 Method Example 1. This is of a main() method using a another method, f. public class FirstMethod

More information

CS 177 Week 5 Recitation Slides. Loops

CS 177 Week 5 Recitation Slides. Loops CS 177 Week 5 Recitation Slides Loops 1 Announcements Project 1 due tonight at 9PM because of evac. Project 2 is posted and is due on Oct. 8th 9pm Exam 1 Wednesday Sept 30 6:30 7:20 PM Please see class

More information

COMP-202 Unit 0: Course Details

COMP-202 Unit 0: Course Details COMP-202 Unit 0: Course Details CONTENTS: Focus of the Course and Prerequisites Outline and Textbook Course Structure and Grading Scheme Computer Lab Info and Required Software Getting started thinking

More information

COMP-202: Foundations of Programming. Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015

COMP-202: Foundations of Programming. Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015 COMP-202: Foundations of Programming Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015 Announcements Midterm Exams on 4 th of June (12:35 14:35) Room allocation will be announced soon

More information

QUIZ on Ch.5. Why is it sometimes not a good idea to place the private part of the interface in a header file?

QUIZ on Ch.5. Why is it sometimes not a good idea to place the private part of the interface in a header file? QUIZ on Ch.5 Why is it sometimes not a good idea to place the private part of the interface in a header file? Example projects where we don t want the implementation visible to the client programmer: The

More information

! Learn how to think like a computer scientist. ! Learn problem solving. ! Read and write code. ! Understand object oriented programming

! Learn how to think like a computer scientist. ! Learn problem solving. ! Read and write code. ! Understand object oriented programming 1 TOPIC 1 INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING Topic 1 Introduction to Computer Science and Programming Notes adapted from Introduction to Computing and Programming with Java: A Multimedia

More information

The NetBeans IDE is a big file --- a minimum of around 30 MB. After you have downloaded the file, simply execute the file to install the software.

The NetBeans IDE is a big file --- a minimum of around 30 MB. After you have downloaded the file, simply execute the file to install the software. Introduction to Netbeans This document is a brief introduction to writing and compiling a program using the NetBeans Integrated Development Environment (IDE). An IDE is a program that automates and makes

More information

CONTENTS: Arrays Strings. COMP-202 Unit 5: Loops in Practice

CONTENTS: Arrays Strings. COMP-202 Unit 5: Loops in Practice CONTENTS: Arrays Strings COMP-202 Unit 5: Loops in Practice Computing the mean of several numbers Suppose we want to write a program which asks the user to enter several numbers and then computes the average

More information

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

CMSC 201 Fall 2016 Lab 09 Advanced Debugging CMSC 201 Fall 2016 Lab 09 Advanced Debugging Assignment: Lab 09 Advanced Debugging Due Date: During discussion Value: 10 points Part 1: Introduction to Errors Throughout this semester, we have been working

More information

A function is a named piece of code that performs a specific task. Sometimes functions are called methods, procedures, or subroutines (like in LC-3).

A function is a named piece of code that performs a specific task. Sometimes functions are called methods, procedures, or subroutines (like in LC-3). CIT Intro to Computer Systems Lecture # (//) Functions As you probably know from your other programming courses, a key part of any modern programming language is the ability to create separate functions

More information

COMP-202: Foundations of Programming. Lecture 8: for Loops, Nested Loops and Arrays Jackie Cheung, Winter 2016

COMP-202: Foundations of Programming. Lecture 8: for Loops, Nested Loops and Arrays Jackie Cheung, Winter 2016 COMP-202: Foundations of Programming Lecture 8: for Loops, Nested Loops and Arrays Jackie Cheung, Winter 2016 Review What is the difference between a while loop and an if statement? What is an off-by-one

More information

Java Programming. Computer Science 112

Java Programming. Computer Science 112 Java Programming Computer Science 112 Yay Programming! How did the RPS program go? Did you notice the part where I pointed at the answer on the board that we did together? Biggest problems in NumbersAndMath

More information

Conditionals, Loops, and Style

Conditionals, Loops, and Style Conditionals, Loops, and Style yes x > y? no max = x; max = y; http://xkcd.com/292/ Fundamentals of Computer Science Keith Vertanen Copyright 2013 Control flow thus far public class ArgsExample public

More information

COMP-202 Unit 2: Java Basics. CONTENTS: Printing to the Screen Getting input from the user Types of variables Using Expressions and Variables

COMP-202 Unit 2: Java Basics. CONTENTS: Printing to the Screen Getting input from the user Types of variables Using Expressions and Variables COMP-202 Unit 2: Java Basics CONTENTS: Printing to the Screen Getting input from the user Types of variables Using Expressions and Variables Tutorial 0 Help with setting up your computer to compile and

More information

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA 1 TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared

More information

Basic Programming Language Syntax

Basic Programming Language Syntax Java Created in 1990 by Sun Microsystems. Free compiler from Sun, commercial from many vendors. We use free (Sun) Java on UNIX. Compiling and Interpreting...are processes of translating a high-level programming

More information

Civil Engineering Computation

Civil Engineering Computation Civil Engineering Computation First Steps in VBA Homework Evaluation 2 1 Homework Evaluation 3 Based on this rubric, you may resubmit Homework 1 and Homework 2 (along with today s homework) by next Monday

More information

CSE 142. Lecture 1 Course Introduction; Basic Java. Portions Copyright 2008 by Pearson Education

CSE 142. Lecture 1 Course Introduction; Basic Java. Portions Copyright 2008 by Pearson Education CSE 142 Lecture 1 Course Introduction; Basic Java Welcome Today: Course mechanics A little about computer science & engineering (CSE) And how this course relates Java programs that print text 2 Handouts

More information

List of Slides 1 Title 2 Chapter 2: Sequential execution and program errors 3 Chapter aims 4 Section 2: Example:Hello world 5 Aim 6 Class: programs ar

List of Slides 1 Title 2 Chapter 2: Sequential execution and program errors 3 Chapter aims 4 Section 2: Example:Hello world 5 Aim 6 Class: programs ar List of Slides 1 Title 2 Chapter 2: Sequential execution and program errors 3 Chapter aims 4 Section 2: Example:Hello world 5 Aim 6 Class: programs are divided into classes 7 Class: public class 8 Class:

More information

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors Outline Overview history and advantage how to: program, compile and execute 8 data types 3 types of errors Control statements Selection and repetition statements Classes and methods methods... 2 Oak A

More information

COMP-202 Unit 9: Exceptions

COMP-202 Unit 9: Exceptions COMP-202 Unit 9: Exceptions Announcements - Assignment 4: due Monday April 16th - Assignment 4: tutorial - Final exam tutorial next week 2 Exceptions An exception is an object that describes an unusual

More information

Chapter 2, Part I Introduction to C Programming

Chapter 2, Part I Introduction to C Programming Chapter 2, Part I Introduction to C Programming C How to Program, 8/e, GE 2016 Pearson Education, Ltd. All rights reserved. 1 2016 Pearson Education, Ltd. All rights reserved. 2 2016 Pearson Education,

More information

COMP-202: Foundations of Programming

COMP-202: Foundations of Programming COMP-202: Foundations of Programming Lecture 3: Basic data types Jackie Cheung, Winter 2016 Review: Hello World public class HelloWorld { } public static void main(string[] args) { } System.out.println("Hello,

More information

Java Programming Constructs Java Programming 2 Lesson 1

Java Programming Constructs Java Programming 2 Lesson 1 Java Programming Constructs Java Programming 2 Lesson 1 Course Objectives Welcome to OST's Java 2 course! In this course, you'll learn more in-depth concepts and syntax of the Java Programming language.

More information

Intro. Speed V Growth

Intro. Speed V Growth Intro Good code is two things. It's elegant, and it's fast. In other words, we got a need for speed. We want to find out what's fast, what's slow, and what we can optimize. First, we'll take a tour of

More information

Most of the class will focus on if/else statements and the logical statements ("conditionals") that are used to build them. Then I'll go over a few

Most of the class will focus on if/else statements and the logical statements (conditionals) that are used to build them. Then I'll go over a few With notes! 1 Most of the class will focus on if/else statements and the logical statements ("conditionals") that are used to build them. Then I'll go over a few useful functions (some built into standard

More information

How to make a "hello world" program in Java with Eclipse *

How to make a hello world program in Java with Eclipse * OpenStax-CNX module: m43473 1 How to make a "hello world" program in Java with Eclipse * Hannes Hirzel Based on How to make a "hello world" program in Java. by Rodrigo Rodriguez This work is produced by

More information

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University Lecture 2 COMP1406/1006 (the Java course) Fall 2013 M. Jason Hinek Carleton University today s agenda a quick look back (last Thursday) assignment 0 is posted and is due this Friday at 2pm Java compiling

More information

Functional Programming in Haskell Prof. Madhavan Mukund and S. P. Suresh Chennai Mathematical Institute

Functional Programming in Haskell Prof. Madhavan Mukund and S. P. Suresh Chennai Mathematical Institute Functional Programming in Haskell Prof. Madhavan Mukund and S. P. Suresh Chennai Mathematical Institute Module # 02 Lecture - 03 Characters and Strings So, let us turn our attention to a data type we have

More information

Yup, left blank on purpose. You can use it to draw whatever you want :-)

Yup, left blank on purpose. You can use it to draw whatever you want :-) Yup, left blank on purpose. You can use it to draw whatever you want :-) Chapter 1 The task I have assigned myself is not an easy one; teach C.O.F.F.E.E. Not the beverage of course, but the scripting language

More information

Lecture 1 - Introduction (Class Notes)

Lecture 1 - Introduction (Class Notes) Lecture 1 - Introduction (Class Notes) Outline: How does a computer work? Very brief! What is programming? The evolution of programming languages Generations of programming languages Compiled vs. Interpreted

More information

Object-Oriented Programming

Object-Oriented Programming Object-Oriented Programming Java Syntax Program Structure Variables and basic data types. Industry standard naming conventions. Java syntax and coding conventions If Then Else Case statements Looping (for,

More information

Welcome to CSE 142! Zorah Fung University of Washington, Spring Building Java Programs Chapter 1 Lecture 1: Introduction; Basic Java Programs

Welcome to CSE 142! Zorah Fung University of Washington, Spring Building Java Programs Chapter 1 Lecture 1: Introduction; Basic Java Programs Welcome to CSE 142! Zorah Fung University of Washington, Spring 2015 Building Java Programs Chapter 1 Lecture 1: Introduction; Basic Java Programs reading: 1.1-1.3 1 What is computer science? computers?

More information

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners Getting Started Excerpted from Hello World! Computer Programming for Kids and Other Beginners EARLY ACCESS EDITION Warren D. Sande and Carter Sande MEAP Release: May 2008 Softbound print: November 2008

More information

Introduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords

Introduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords Introduction to Java Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords Program Errors Syntax Runtime Logic Procedural Decomposition Methods Flow of Control

More information

17 Hello world 18 Type: String: literal 19 Standard API: System: out.println() 20 Hello world 21 Statement 22 Statement: simple statements are ended w

17 Hello world 18 Type: String: literal 19 Standard API: System: out.println() 20 Hello world 21 Statement 22 Statement: simple statements are ended w List of Slides 1 Title 2 Chapter 2: Sequential execution and program errors 3 Chapter aims 4 Section 2: Example:Hello world 5 Aim 6 Class: programs are divided into classes 7 Class: public class 8 Class:

More information

Arrays. myints = new int[15];

Arrays. myints = new int[15]; Arrays As you know from COMP 202 (or equivalent), an array is a data structure that holds a set of elements that are of the same type. Each element in the array can be accessed or indexed by a unique number

More information

First Java Program - Output to the Screen

First Java Program - Output to the Screen First Java Program - Output to the Screen These notes are written assuming that the reader has never programmed in Java, but has programmed in another language in the past. In any language, one of the

More information

The data in the table are arranged into 12 rows and 12 columns. The process of printing them out can be expressed in a pseudocode algorithm as

The data in the table are arranged into 12 rows and 12 columns. The process of printing them out can be expressed in a pseudocode algorithm as Control structures in Java are statements that contain statements. In particular, control structures can contain control structures. You've already seen several examples of if statements inside loops,

More information

SESSION 3 Programming Languages for Objects

SESSION 3 Programming Languages for Objects SESSION 3 Programming Languages for Objects Blocks, Loops, and Branches Algorithm Development The while and do..while Statements The for Statement The if Statement The switch Statement Introduction to

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG 1 Notice Prepare the Weekly Quiz The weekly quiz is for the knowledge we learned in the previous week (both the

More information

Introduction to the Java Basics: Control Flow Statements

Introduction to the Java Basics: Control Flow Statements Lesson 3: Introduction to the Java Basics: Control Flow Statements Repetition Structures THEORY Variable Assignment You can only assign a value to a variable that is consistent with the variable s declared

More information

Problem One: A Quick Algebra Review

Problem One: A Quick Algebra Review CS103A Winter 2019 Solutions for Week One Handout 01S Problem One: A Quick Algebra Review In the first week of CS103, we'll be doing a few proofs that will require some algebraic manipulations and reasoning

More information

An overview of Java, Data types and variables

An overview of Java, Data types and variables An overview of Java, Data types and variables Lecture 2 from (UNIT IV) Prepared by Mrs. K.M. Sanghavi 1 2 Hello World // HelloWorld.java: Hello World program import java.lang.*; class HelloWorld { public

More information