Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu https://xliu12.mysite.syr.edu/

Slides:



Advertisements
Similar presentations
1 Classes and Objects in Java Parameter Passing, Delegation, Visibility Control, and Object Cleanup.
Advertisements

Introduction to C Programming
Procedural programming in Java
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
Constructors & An Introduction to Methods. Defining Constructor – Car Example Public class car { String Model; double speed; String colour; { Public Car.
5/17/ Programming Constructs... There are several types of programming constructs in JAVA. - If-else construct or ternary operator - while - do-while.
Introduction to Computers and Programming Lecture 11: Introduction to Methods Professor: Evan Korth New York University.
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu.
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu
Introduction to Computers and Programming Introduction to Methods in Java.
ISQA 360 – July 8, 2002 Methods Dr. Sergio Davalos.
 To be able to write larger programs ◦ By breaking them down into smaller parts and passing data between the parts.  To understand the concepts of Methods.
Computer Programming Lab(4).
Week 2 - Friday.  What did we talk about last time?  Data representation  Binary numbers  Types  int  boolean  double  char  String.
Passing Other Objects Strings are called immutable which means that once a String object stores a value, it never changes –recall when we passed a message.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
ITEC 320 Lecture 16 Packages (1). Review Questions? –HW –Exam Nested records –Benefits –Downsides.
Introduction to Classes SWE 344 Internet Protocols & Client Server Programming.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu
Week 6 - Wednesday.  What did we talk about last time?  Exam 1 post-mortem  Recursive running time.
Passing Other Objects Strings are called immutable which means that once a String object stores a value, it never changes –recall when we passed a message.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
Week 2 - Wednesday.  What did we talk about last time?  Data representation  Binary numbers  Types  int  boolean  double  char  String.
Arrays Chapter 8. What if we need to store test scores for all students in our class. We could store each test score as a unique variable: int score1.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Methods (a.k.a. Functions)
1 BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA AND DEFINITE LOOPS.
Procedural programming in Java Methods, parameters and return values.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
1 Methods Introduction to Methods Passing Arguments to a Method More About Local Variables Returning a Value from a Method Problem Solving with Methods.
Java methods Methods break down large problems into smaller ones Your program may call the same method many times saves writing and maintaining same code.
Calling Methods. Review  We can declare and create objects: Dinosaur dino; dino = new Dinosaur();  We can also shortcut the first two lines: Dinosaur.
1 Chapter 6 Methods. 2 Motivation Find the sum of integers from 1 to 10, from 20 to 30, and from 35 to 45, respectively.
User Defined Methods Methods are used to divide complicated programs into manageable pieces. There are predefined methods (methods that are already provided.
Catie Welsh February 23,  Lab 4 due on Friday  Lab 5 will be assigned on Friday 2.
Written by: Dr. JJ Shepherd
Announcements Final Exam: TBD. Static Variables and Methods static means “in class” methods and variables static variable: one per class (not one per.
Chapter 5 : Methods Part 2. Returning a Value from a Method  Data can be passed into a method by way of the parameter variables. Data may also be returned.
COP 2220 Computer Science I Topics –Breaking Problems Down –Functions –User-defined Functions –Calling Functions –Variable Scope Lecture 4.
Methods What is a method? Main Method the main method is where a stand alone Java program normally begins execution common compile error, trying.
JAVA METHODS (FUNCTIONS). Why are they called methods? Java is a strictly object-oriented programming language Methods are functions inside of objects.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
Chapter 9 Introduction to Arrays Fundamentals of Java.
Introduction to Programming G50PRO University of Nottingham Unit 6 : Control Flow Statements 2 Paul Tennent
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Java 5 Class Anatomy. User Defined Classes To this point we’ve been using classes that have been defined in the Java standard class library. Creating.
Methods Matthew Harrison. Overview ● There are five main aspects of methods... ● 1) Modifiers – public, private ● 2) Method Name ● 3) Parameters ● 4)
Functions + Overloading + Scope
Department of Computer Science
Practice + Method Xiaozhong Liu
using System; namespace Demo01 { class Program
Advanced Programming in Java
Method Mark and Lyubo.
Starting Out with Java: From Control Structures through Objects
Introduction to Computer Programming
Functions Used to write code only once Can use parameters.
Computing Adjusted Quiz Total Score
Introduction to Application Programming
Recursive GCD Demo public class Euclid {
Chapter 6 Methods.
AKA the birth, life, and death of variables.
class PrintOnetoTen { public static void main(String args[]) {
Scope of variables class scopeofvars {
Local variables and how to recognize them
Methods/Functions.
Presentation transcript:

Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu

What is the ideal programming style? public static void main(String[] args) { String query = “……”; if (spellcorrect(query)) { results = search(query); results = rank(results); show(results); } else { query = suggestQuery(query); updateQuery(query); }

Procedure public static void main(String[] args) { int number; … ABC (number) … } Private static void ABC (int targetnum) { … }

Concept of Procedures and Functions All modern programming languages have a way to break the program into smaller pieces by placing a piece of code in a procedure or function – This type of modularization is good programming design – Often entire sections of code need to be repeated in different parts of the program, for example sorting a list of data, and making it into a procedure streamlines the process Write once, use many times Java calls these methods

Method definition public static int squareR ( int y) { // variable to hold the square of y int ysquared; ysquared = y * y; return ysquared; } scope keywordsreturn typemethod nameformal parameter list method header method body

Procedure – organize your code public static void main(String[] args) { String query = “???”; String results; …… results = search (query); results = rank (results); show_results(results); … } private static String search (String query) { String results; … return results; }

Wine or water? public static void main(String[] args) { String drink; int age = ??; if (oldenough(age)) { drink = “wine”; } else { drink = “water”; } oldenough(age) Returns a boolean result

…100 public static void main(String[] args) { int result = 0; int start = 1; int end = 100; result = sumnums (start, end); System.out.println(result); } sumnums (start, end) Returns int

Convert temperature public static void main(String[] args) { double Fahrenheit, Celsius = ??; Fahrenheit = convert_temp (Celsius ); System.out.println(Fahrenheit ); } convert_temp (Celsius ) Returns double

Practice … … 1500 public static int sumnum (int startnum, int endnum, int intervalnum) { int number = startnum; int result = 0; while (number < endnum) { result = result + number; number = number + intervalnum; } return result; }

Your IST256 course score? Lab – 15%; Assignment – 45%; two exams – 40% : A; 75 – 89: B; 60 – 74: C; 45 – 60 D; 0 – 45 T.T