Programming Fundamentals I Java Programming ICE0124ITB0121 - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Programming Fundamentals I Java Programming ICE0124ITB0121

Description:

Hwang, Kim. 6. Understanding an array (Cont'd) Initialization of an Array ... Hwang, Kim. 10. Practice together once again! ... Hwang, Kim. 15. Assign Homework ... – PowerPoint PPT presentation

Number of Views:107
Avg rating:3.0/5.0
Slides: 16
Provided by: eruh
Category:

less

Transcript and Presenter's Notes

Title: Programming Fundamentals I Java Programming ICE0124ITB0121


1
Programming 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)

2
4 Array practice
3
Agenda for Today
  • Understanding an array
  • Practice together!
  • Assign Homework 4

4
Understanding 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

5
Understanding 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

6
Understanding 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

7
Practice together!
  • Store every odd number between 0 and 100 in an
    array and add them up.

8
Practice together! (Contd)
9
Practice 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
10
Practice together once again!
  • Make a program to find Max or min value among 10
    inputs. Store 10 values in an array and do this.

11
Practice together once again! (Contd)
12
Practice 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
13
Practice 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
14
Assign Homework 4
  • Do Exercise 8.15. Deitel p.413

15
Assign 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
Write a Comment
User Comments (0)
About PowerShow.com