Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu https://xliu12.mysite.syr.edu/"— Presentation transcript:

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

2 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); }

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

4 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

5 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

6 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; }

7 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

8 1+2+3+4+5…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

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

10 Practice 2 + 4 + 6 + 8 … 1000 3 + 6 + 9 + 12 … 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; }

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


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

Similar presentations


Ads by Google