Computer Science A 1: 3/2. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
IT151: Introduction to Programming
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
How to Create a Java program CS115 Fall George Koutsogiannakis.
CMT Programming Software Applications
Some basic I/O.
Java Intro. A First Java Program //The Hello, World! program in Java public class Hello { public static void main(String[] args) { System.out.println("Hello,
Datalogi A 1: 8/9. Book: Cay Horstmann: Big Java or Java Consepts.
01 Introduction1June Introduction CE : Fundamental Programming Techniques.
Java An introduction. Example 1 public class Example1 { public static void main (String [] args) { System.out.println (“This is the first example”); int.
Computer Science A 2: 6/2. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated.
Relational Operators Control structures Decisions using “if” statements  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course.
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
Hello, world! Dissect HelloWorld.java Compile it Run it.
COMP 14: Primitive Data and Objects May 24, 2000 Nick Vallidis.
1 The First Step Learning objectives write Java programs that display text on the screen. distinguish between the eight built-in scalar types of Java;
C Programming. Chapter – 1 Introduction Study Book for one month – 25% Learning rate Use Compiler for one month – 60%
CSE 131 Computer Science 1 Module 1: (basics of Java)
11 Getting Started with C# Chapter Objectives You will be able to: 1. Say in general terms how C# differs from C. 2. Create, compile, and run a.
COMP 110: Introduction to Programming Tyler Johnson January 14, 2009 MWF 11:00AM-12:15PM Sitterson 014.
Hello World 2 What does all that mean?.
C# B 1 CSC 298 Writing a C# application. C# B 2 A first C# application // Display Hello, world on the screen public class HelloWorld { public static void.
CS 106 Introduction to Computer Science I 01 / 25 / 2010 Instructor: Michael Eckmann.
CS107 Introduction to Computer Science Java Basics.
1 CSC 201: Computer Programming I B. S. Afolabi. Introduction  3 unit course  2 hours of lecture/week Thursdays 4.00pm – 6.00pm Mondays 4.00pm – 6.00pm.
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
Introduction to Computers and Java Chapter 1.3. A Sip of Java: Outline History of the Java Language Applets A First Java Program Compiling a Java Program.
OOP (Java): Simple/ OOP (Java) Objectives – –give some simple examples of Java applications and one applet 2. Simple Java Programs Semester.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
CSE 131 Computer Science 1 Module 1: (basics of Java)
Input & Output In Java. Input & Output It is very complicated for a computer to show how information is processed. Although a computer is very good at.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Chapter 2: Java Fundamentals
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A Simple Program: Printing a.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Introduction to programming in the Java programming language.
Jens Dalsgaard Nielsen Jan Dimon Bendtsen Dept. of Electronic Systems Basic Programming INS-basis GF, PDP and HST.
CS 106 Introduction to Computer Science I 01 / 31 / 2007 Instructor: Michael Eckmann.
Can we talk?. In Hello World we already saw how to do Standard Output. You simply use the command line System.out.println(“text”); There are different.
Programming Fundamentals 2: Simple/ F II Objectives – –give some simple examples of Java applications and one applet 2. Simple Java.
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
Lecture 4 – Scanner & Style. Console Output The console that starts a Java application is typically known as the standard output device. The standard.
Introduction to Computing Concepts Note Set 15. JOptionPane.showMessageDialog Message Dialog Allows you to give a brief message to the user Can be used.
Scott Marino MSMIS Kean University MSAS5104 Programming with Data Structures and Algorithms Week 1 Scott Marino.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
CS 177 Recitation Week 1 – Intro to Java. Questions?
Chapter 2: Data and Expressions. Variable Declaration In Java when you declare a variable, you must also declare the type of information it will hold.
CS 106 Introduction to Computer Science I 01 / 24 / 2007 Instructor: Michael Eckmann.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
UFCFY5-30-1Multimedia Studio Coding for Interactive Media Fundamental Concepts.
CCSA 221 Programming in C CHAPTER 3 COMPILING AND RUNNING YOUR FIRST PROGRAM 1 ALHANOUF ALAMR.
Introduction to java (class and object). Programming languages: –Easier to understand than CPU instructions –Needs to be translated for the CPU to understand.
Lecture 4 – Scanner & Style
Computer Programming Your First Java Program: HelloWorld.java.
CompSci 230 S Programming Techniques
Introduction to Computer Science / Procedural – 67130
Introduction to.
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Hello World 2 What does all that mean?.
An Introduction to Java – Part I, language basics
MSIS 655 Advanced Business Applications Programming
Java Intro.
Introduction to Java Brief history of Java Sample Java Program
F II 2. Simple Java Programs Objectives
Computer Programming-1 CSC 111
How to Run a Java Program
Presentation transcript:

Computer Science A 1: 3/2

Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor, libraries. A bit about software engineering – methods used in constructing programs. A bit about graphics Freeware book

Computer Science A What you have to do 6 * home work 3 * mini-project 1 * oral test based on mini-project All information available on

Java programs public class Hello{ public static void main(String[] args){ System.out.println(”Hello world”); } A program contains classes (here Hello )chapters classes contains methods (here main )paragraphs methods contains statements (here System.out… ) One class has the same name as the file ( Hello.java ) One method in that class is called main

Java programs Extra spaces and newlines does not matter, except: No newlines in text strings ( ”… ” ) At least one space between words ( public static ) Use indentations to make programs readable. The compiler ignores it, but I don’t Case does matter String, class Hello and Hello.java

Java statements Print out System.out.println( …. Reading input … Declare variables int counter; Change values of variables counter = 1; this can be combined into int counter = 1; Method calls if statements while statements

Expressions and values For now: strings and numbers String name=”Hello”; int counter = 2; (case does matter) (three more types of values; some ways to construct more complex values from simple ones.) Operations + on strings concatenate +,-, *,/ on numbers add, subtract, multiply, divide

Assignment int counter; create a variable called counter counter=1; store the value 1 in the variable counter=counter+1; compute the value of the expression counter+1 and store that in the variable. counter now has the value 2

Input input via command prompt screen java.util.Scanner in= new java.util.Scanner(System.in); System.out.println("type a name"); String line=in.nextLine(); System.out.println("type a number"); int num=in.nextInt(); System.out.println("read: "+line+" "+num); Read a line and a number and save what you read in newly created variables

Input nextLine reads text until next linebreak, returns the text and skips the linebreak nextInt skips spaces and newlines until start of a number, it reads and returns the number Notice that java and DOS does not read anything until you have finished a line. After a nextInt call the next symbol is probably a newline character.

Input input via dialog windows String name= javax.swing.JOptionPane.showInputDialog( "type a name"); String num = javax.swing.JOptionPane.showInputDialog( "type a number"); Output: javax.swing.JOptionPane.showMessageDialog( null,"read: "+name+" "+num); Read a line and a number and save what you read in newly created variables

TextIO Eck has written his own class to do Input/output. To use it you need to download it from his web page and place it in the same directory as your program. To read a number write int num = TextIO.getlnInt(); To read a String write String s = TextIO.getln();

Java programs public class Hello{ public static void main(String[] args){ System.out.println(”Hello world”); } Public: you can hide stuff from other parts of your program. Here: everything can be seen everywhere static: some stuff may only exist for some of the time a program is executed. Here: it exists all the time void: methods may return values. Here: it does not return anything. String[] args: When you start a program it may have some command line arguments (you drop a file on a program etc). Here: it is not used.

Objects On Friday: expressions, variables etc Eck chapter 2: 2.1 – 2.5 The important part is The rest you can always look up when you need it