intro
13 Pages

intro

Course Number: CS 111, Fall 2009

College/University: BU

Word Count: 1360

Rating:

Document Preview

Introduction to Computer Science I Course Overview Programming in Java Computer Science 111 Boston University Spring 2009 David G. Sullivan, Ph.D. Welcome to CS 111! Computer science is not so much the science of computers as it is the science of solving problems using computers. Eric Roberts This course covers: the process of developing algorithms to solve problems the process of developing computer...

Unformatted Document Excerpt
Coursehero >> Massachusetts >> BU >> CS 111

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

to Introduction Computer Science I Course Overview Programming in Java Computer Science 111 Boston University Spring 2009 David G. Sullivan, Ph.D. Welcome to CS 111! Computer science is not so much the science of computers as it is the science of solving problems using computers. Eric Roberts This course covers: the process of developing algorithms to solve problems the process of developing computer programs to express those algorithms Computer Science and Programming There are many different fields within CS, including: software systems computer architecture networking programming languages, compilers, etc. theory AI Experts in many of these fields dont do much programming! However, learning to program will help you to develop ways of thinking and solving problems used in all fields of CS. A Rigorous Introduction Intended for: CS, math, and physical science concentrators others who want a rigorous introduction no programming background required, but can also benefit people with prior background Allow for 10-15 hours of work per week start work early! Less rigorous alternatives include: CS 101: overview of CS, a bit of programming CS 105: databases and data mining 1/3 of course is learning to program in Python CS 108: a less rigorous intro. to programming also uses Python CS 111 Requirements Attendance at and participation in lectures and labs (10%) email us ahead of time if you have a conflict labs begin next week held in the CS teaching lab, EMA 304 complete Lab 0 sometime this week (see course website) Ten problem sets (40%) must be your own work: see syllabus for details Three quizzes (25%) no makeups, so please mark your calendars! Final exam (25%) Textbook Building Java Programs by Stuart Reges and Marty Stepp (Addison Wesley, 2008). were using a custom Boston University edition available at Barnes & Noble omits material that we don't cover cheaper! the standard edition is also fine Also required: The CS 111 Coursepack contains all of the lecture notes available at Fedex Kinkos on Cummington Street Course Staff Instructor: Dave Sullivan (dgs@cs.bu.edu) Teaching fellow: Tai-Peng Tian (tian@cs.bu.edu) Office hours and contact info. will be available on the course website: http://www.cs.bu.edu/courses/cs111 For general course-related questions, email: cs111-staff@cs.bu.edu which will forward your question to the full course staff. Other Details of the Syllabus Academic conduct Policies: lateness please don't request an extension unless it's an emergency! grading Please read the syllabus carefully and make sure that you understand the policies and follow them carefully. Let us know if you have any questions. Algorithms In order to solve a problem using a computer, you need to come up with one or more algorithms. An algorithm is a step-by-step description of how to accomplish a task. An algorithm must be: precise: specified in a clear and unambiguous way effective: capable of being carried out Example of Defining an Algorithm Algorithm for Finding My Office 1. Go to the entrance to the MCS (math/CS) building at 111 Cummington Street behind Warren Towers. (It is the pink part of the building.) 2. Cross the street to the pair of doors across from MCS. 3. Enter those doors and take an immediate right. Algorithm for Finding My Office (cont.) 4. Open the door to the stairway and go up to the second floor. 5. Upon exiting the stairs, turn right. 6. Take an immediate left into a small hallway. 7. My office is the first door on the left (PSY 228D). Programming Programming involves expressing an algorithm in a form that a computer can interpret. We will be using the Java programming language. one of many possible languages The key concepts of the course transcend this language. Programs and Classes In Java, all programs consist of one of more classes. For now: we'll limit ourselves to writing a single class you can just think of a class as a container for your program Example: a program that displays a simple message: public class HelloWorld { public static void main(String[] args) { System.out.println("hello, world"); } } A class must be defined in a file with a name of the form <classname>.java for the class above, the name would be HelloWorld.java Using an IDE An integrated development environment (IDE) is an application helps that you develop programs. Well use the Dr. Java IDE. Lab 0 tells you how to obtain and install it. Please do so ASAP. With an IDE, you do the following: use its built-in text editor to write your code instruct the IDE to compile the code instruct the IDE to run the program debug as needed, using the IDE's debugging tools Using Dr. Java Format of a Java Class General syntax: public class <name> { code goes here } where <name> is replaced by the name of the class. Notes: the class begins with a header: public class <name> the code inside the class is enclosed in curly braces ({ and }) Methods A method is a collection of instructions that perform some action or computation. Every Java program must include a method called main. contains the instructions that will be executed first when the program is run Our example program includes a main method with a single instruction: public class HelloWorld { public static void main(String[] args) { System.out.println("hello, world"); } } Methods (cont.) General syntax for the main method: public static void main(String[] args) { <statement>; <statement>; <statement>; } where each <statement> is replaced by a single instruction. Notes: the main method always begins with the same header: public static void main(String[] args) the code inside the method is enclosed in curly braces each statement typically ends with a semi-colon the statements are carried out (executed) sequentially, one after the other Identifiers Used to name the components of a Java program like classes and methods. Rules: must begin with a letter (a-z, A-Z), $, or _ can be followed by any number of letters, numbers, $, or _ spaces are not allowed cannot be the same as a keyword a word like class that is part of the language itself (see the book) Which of these are not valid identifiers? n1 avgSalary num_values course name 2n Java is case-sensitive (for both identifiers and keywords). example: HelloWorld is not the same as helloWorld Conventions for Identifiers Capitalize class names. example: HelloWorld Do not capitalize method names. example: main Capitalize internal words within the name. example: HelloWorld Printing Text public class HelloWorld { public static void main(String[] args) { System.out.println("hello, world"); } } Our program contains a single statement that prints some text. The printed text appears in a window known as the console. Printing Text (cont.) The general format of such statements is: System.out.println("<text>"); where &l...
MOST POPULAR MATERIALS FROM CS 111
MOST POPULAR MATERIALS FROM CS
MOST POPULAR MATERIALS FROM BU