Title: Programming Fundamentals I Java Programming ICE0124ITB0121
1Programming Fundamentals I Java
Programming(ICE0124/ITB0121)
July 25th, 2005 Lab No. 4
- Tae-ho Hwang (fanteo.AT.icu.ac.kr)
- Eru Hojin Kim (eruhkim.AT.icu.ac.kr)
24 Array practice
3Agenda for Today
- Understanding an array
- Practice together!
- Assign Homework 4
4Understanding an array
- Meaning of Array
- An Array is something like a list of variables
- Declaration of Array and example
- Base_Type Array_Name new Base_TypeLength
- char symbol new char80
- double reading new double100
- Species specimen new Species80
5Understanding an array (Contd)
- Array Terminology
- temperaturen2 32
-
- temperature is Array name
- n2 is Index (OR subscript)
- temperauturen2 is Indexed variable
- 32 is Value of Indexed variable
6Understanding an array (Contd)
- Initialization of an Array
- double reading 3.3, 15.8, 9.8
- OR,
- double reading new double3
- reading0 3.3
- reading1 15.8
- reading2 9.8
7Practice together!
- Store every odd number between 0 and 100 in an
array and add them up.
8Practice together! (Contd)
9Practice together! (Contd)
- public class Lab4_1
- public static void main(String args)
- int numbers new int50
- int sum 0
- int i
- for (i0 i
- numbersi i21
-
- for (i0 i
- sum sum numbersi
-
- System.out.println(sum)
-
Lab4_1.java
10Practice together once again!
- Make a program to find Max or min value among 10
inputs. Store 10 values in an array and do this.
11Practice together once again! (Contd)
12Practice together once again! (Contd)
- import java.util.Scanner
- public class Lab4_2
- public static void main(String args)
- Scanner input new Scanner(System.in)
- int numbers new int10
- int max, min
- int i
- for (i0 i
- System.out.printf("Enter the dth integer
number ", i)
- numbersi input.nextInt()
-
Lab4_2.java
13Practice together once again! (Contd)
- max numbers0
- min numbers0
- for (i0 i
- if (numbersi max) max numbersi
- if (numbersi
-
- System.out.printf("Maximum d\nMinimum d",
max, min)
-
Lab4_2.java
14Assign Homework 4
- Do Exercise 8.15. Deitel p.413
15Assign Homework 4 (Contd)
- Submission
- Compress the files to zip file (not alz) named
like ICE0124_20050001_HW4.zip
- Mail subject should be likeICE0124 Homework 4
by 20050001 ???
- Send to eruhkim.AT.icu.ac.kr
- Due date 2005-08-01 180000
- 15 penalty for 1-day late submission, 50
penalty for 2-day late submission, zero point
after 2-day late submission.
- Demerit mark for non-standardized submission