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/index.htm.

Similar presentations


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

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

2 Information problem… Input Output An ObjectA Variable (String, Integer, Double) A list of Object An Array of… (Strings, integers, doubles)

3 Temperature File, 5 temperatures 30.5 -15.3 0 60.35 18.12 double [ ] temperatures = new double[5]; //Write to those variables (Array) temperatures [0] temperatures [1] temperatures [2] temperatures [3] temperatures [4]

4 Array Declarations String Array String [ ] students = new String [25]; String [ ] students = new String [25]; int Array int [ ] age = new int [100]; int [ ] age = new int [100]; double double [ ] heights = new double [50]; double [ ] heights = new double [50];Type Array name Variable value

5 Average of numbers int [ ] numbers = new int [50]; … //e.g.read from a file ‘Average numbers??? int sum = 0; double average; for (int index = 0; index<50; index++) { sum = sum + numbers [index]; } average = ????????

6 2 – Dimensional Array int [ ][ ] numbers = new int [2][3]; numbers (0, 0)numbers (0, 1)numbers (0, 2)numbers (0, 3) numbers (1, 0)numbers (1, 1)numbers (1, 2)numbers (1, 3) numbers (2, 0)numbers (2, 2) numbers (2, 3)

7 2 – Dimensional Array int [ ][ ] numbers = new int [3][5]; double average, sum = 0; for (int row= 0; row<3; row++) { for (int col = 0; col < 5; col++) { sum = sum + numbers [row] [col]; } average = ?????????

8 Practice int[ ] numbers = new int[20], squares = new int[20]; for (int i = 0; i < numbers.length; i++) { numbers[i] = i + 1; } //Compute squares??? //Average of squares???


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

Similar presentations


Ads by Google