Computer Programming 12 Mr. Jean April 24, 2014. The plan: Video clip of the day Upcoming Quiz Sample arrays Using arrays More about arrays.

Slides:



Advertisements
Similar presentations
Etter/Ingber Arrays and Matrices. Etter/Ingber One-Dimensional Arrays 4 An array is an indexed data structure 4 All variables stored in an array are of.
Advertisements

Arrays.
Arrays Chapter 6. Outline Array Basics Arrays in Classes and Methods Sorting Arrays Multidimensional Arrays.
CS 106 Introduction to Computer Science I 02 / 18 / 2008 Instructor: Michael Eckmann.
Arrays. Memory organization Table at right shows 16 bytes, each consisting of 8 bits Each byte has an address, shown in the column to the left
Copyright 2008 by Pearson Education Building Java Programs Chapter 7 Lecture 7-1: Arrays reading: 7.1 self-checks: #1-9 videos: Ch. 7 #4.
Arrays Chapter 6 Chapter 6.
ECE122 L14: Two Dimensional Arrays March 27, 2007 ECE 122 Engineering Problem Solving with Java Lecture 14 Two Dimensional Arrays.
Multidimensional Arrays in Java Vidhu S. Kapadia.
Arrays CS Feb Announcements Exam 1 Grades on Blackboard Project 2 scores: end of Class Project 4, due date:20 th Feb –Snakes & Ladders Game.
CS 106 Introduction to Computer Science I 10 / 04 / 2006 Instructor: Michael Eckmann.
CS102--Object Oriented Programming Lecture 6: – The Arrays class – Multi-dimensional arrays Copyright © 2008 Xiaoyan Li.
 2003 Prentice Hall, Inc. All rights reserved. 1 Arrays –Structures of related data items –Static entity (same size throughout program) A few types –Pointer-based.
1 CSCE 1030 Computer Science 1 Arrays Chapter 7 in Small Java.
Chapter 8 Multidimensional Arrays C Programming for Scientists & Engineers with Applications by Reddy & Ziegler.
More Arrays Length, constants, and arrays of arrays By Greg Butler.
Java Unit 9: Arrays Declaring and Processing Arrays.
 2006 Pearson Education, Inc. All rights reserved Arrays.
Computer Programming 12 Mr. Jean May 8 th, The plan: Video clip of the day Upcoming Assessment Bot.java.
Introduction to Arrays in Java Corresponds with Chapter 6 of textbook.
Arrays Part 9 dbg. Arrays An array is a fixed number of contiguous memory locations, all containing data of the same type, identified by one variable.
ARRAYS 1 Week 2. Data Structures  Data structure  A particular way of storing and organising data in a computer so that it can be used efficiently 
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper.
 2005 Pearson Education, Inc. All rights reserved. 1 Arrays.
Arrays Module 6. Objectives Nature and purpose of an array Using arrays in Java programs Methods with array parameter Methods that return an array Array.
Problem Solving using the Java Programming Language May 2010 Mok Heng Ngee Day 5: Arrays.
Computer Science 12 Mr. Jean May 2 nd, The plan: Video clip of the day Review of common errors in programs 2D Arrays.
ARRAYS 1 TOPIC 8 l Array Basics l Arrays and Methods l Programming with Arrays Arrays.
Chapter 8: Collections: Arrays. 2 Objectives One-Dimensional Arrays Array Initialization The Arrays Class: Searching and Sorting Arrays as Arguments The.
Two dimensional arrays in Java Computer Science 3 Gerb Objective: Use matrices in Java.
Java Script: Arrays (Chapter 11 in [2]). 2 Outline Introduction Introduction Arrays Arrays Declaring and Allocating Arrays Declaring and Allocating Arrays.
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
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.
ARRAYS Computer Engineering Department Java Course Asst. Prof. Dr. Ahmet Sayar Kocaeli University - Fall
Course Title Object Oriented Programming with C++ Course instructor ADEEL ANJUM Chapter No: 05 ARRAY 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER) 1.
Arrays. Related data items Collection of the same types of data. Static entity – Same size throughout program.
How do you do the following? Find the number of scores within 3 points of the average of 10 scores? What kind of a tool do you need? Today’s notes: Include.
Arrays-. An array is a way to hold more than one value at a time. It's like a list of items.
Arrays.
IT259 Foundation of Programming Using Java Unit 9 Seminar : (Chapter 8 ) Instructor : Vladimir Gubanov, PhD
CS 180 Recitation 7 Arrays. Used to store similar values or objects. An array is an indexed collection of data values of the same type. Arrays are the.
Arrays.
Arrays An array is an indexed data structure which is used to store data elements of the same data type. An array is an indexed data structure which is.
Chapter 8: Part 3 Collections and Two-dimensional arrays.
CiS 260: App Dev I. 2 Introduction to Arrays n An array is an object that contains a collection of components (_________) of the same data type. n For.
When constructing a two-dimensional array, specify how many rows and columns are needed: final int ROWS = 3; final int COLUMNS = 3; String[][] board =
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Arrays in java Unit-1 Introduction to Java. Array There are situations where we might wish to store a group of similar type of values in a variable. Array.
Week 6 - Friday.  What did we talk about last time?  Loop examples.
Multidimensional Arrays tMyn1 Multidimensional Arrays It is possible to declare arrays that require two or more separate index values to access an element.
C++ Array 1. C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used.
Multi-dimensional Array 1 Multi-dimensional array refers to an array with more than one index. It is a logical representation. On physical storage, the.
SEQUENTIAL AND OBJECT ORIENTED PROGRAMMING Arrays.
© 2004 Pearson Addison-Wesley. All rights reserved7-1 Array review Array of primitives int [] count; count = new int[10]; Array of objects Grade [] cs239;
 2005 Pearson Education, Inc. All rights reserved Arrays.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 7A Arrays (Concepts)
Arrays An array is a sequence of objects all of which have the same type. The objects are called the elements of the array and are numbered consecutively.
KUKUM-06/07 EKT120: Computer Programming 1 Week 6 Arrays-Part 1.
Chapter 2 Clarifications
Two-Dimensional Arrays
Two-Dimensional Arrays
Array Data Structure Chapter 6
Array Data Structure B.Ramamurthy 11/21/2018 B.Ramamurthy.
Introduction To Programming Information Technology , 1’st Semester
class PrintOnetoTen { public static void main(String args[]) {
Abstract Data Types, Elementary Data Structures and Arrays
Array Data Structure Chapter 6
Arrays in Java.
Week 7 - Monday CS 121.
Presentation transcript:

Computer Programming 12 Mr. Jean April 24, 2014

The plan: Video clip of the day Upcoming Quiz Sample arrays Using arrays More about arrays

Java Quiz: Questions about –Types of variables Int, double, spring –Basic Math operations + - * / % –Order of operations in Java –True Tables –Loops For & While –Arrays

Arrays: Arrays are a contiguous section of memory occupied by the same type of data. This data is accessed by adding an offset (the index) to the address of the first element in the array.

Declaring Arrays: They are declared as follows: [] = new [];

2D Arrays: If you want a multi-dimensional array (e.g. a 2D array has rows and columns) you need the same number of pairs of brackets as the number of dimensions. So that 2D array would be: [][] = new [][];

Sample Code: public static void main(String[] args) { int[] numbers = new int[5]; for (int i = 0; i < numbers.length; i++) numbers[i] = 1; for (int i : numbers) System.out.println(i); }

Sample Arrays:

2D – Arrays: type array_name = new type[rows][cols]; Example Code: int multidim[] = new int[3][]; In a two-dimensional array, –You need to allocate memory for only the first dimension. –You can allocate the remaining dimensions separately. When you allocate memory to the second dimension, you can also allocate different number to each dimension.

Accessing Arrays You need to access various elements of an array to assign, retrieve, and manipulate the values stored in the array. Assigning values to the Elements of an Array –To access a specific array: You need to specify the name of the array and the index number of the element. The index position of the first element in the array is 0.

Accessing Array:

Accessing Various Elements:

User Input into Array:

Outputting Array Variables: Sample Code with a “For” loop with regards to { & } logic sets. Do not forget Java defaults. for(int x=0;x<=9;x++) { System.out.print(" "); numbers[x]=scan.nextDouble(); }

Continue to work on programs Now you should have everything you need to complete the last question on JAVA.

User Input into Array:

Outputting Array Variables: Sample Code with a “For” loop with regards to { & } logic sets. Do not forget Java defaults. for(int x=0;x<=9;x++) { System.out.print(" "); numbers[x]=scan.nextDouble(); }