ArraysContinued040109[1]

ArraysContinued040109[1] - 1 Lecture Notes Objectives...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Lecture Notes Objectives Search an array for an exact match Search an array for a range match Searching an Array for an Exact Match 1. The process of searching an array involves examining each array element to determine whether it matches a particular value. public class ArraysDemo { public static void main(String[ ] args) { boolean itemOrdered = false; int validValues = { 101, 108, 201, 213, 266, 304, 311, 409, 411, 412}; for ( int x = 0; x < validValues.length, ++x) { if itemOrdered = = validValues[x]) validItem = true; }// Checks the itemOrderd value against 10 array Items. 2. Parallel array - two or more arrays that store logically related elements at corresponding indexes. Using parallel arrays, write a program that finds a valid price number and a displays the corresponding cost of an item. import javax.swing.*; public class FindPrice { public static void main(String[ ] args) { boolean validItem = false; int [ ] validValues = { 101, 108, 201, 213, 266, 304, 311, 409, 411, 412};
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

ArraysContinued040109[1] - 1 Lecture Notes Objectives...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online