HW05 Solution3

HW05 Solution3 - int index = BinarySearch.binarySearch(id,

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 // Solution to Homework #5, Problem #3 import javax.swing.JOptionPane public class HW5_3 { public static void main(String[] args) { String[] name = {"Elanore", "Bill", "Alice", "Daniel", "Frank", "Clara"} int[] id = {100, 101, 102, 103, 104, 105} String numString = JOptionPane.showInputDialog("Enter an ID number:")
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: int index = BinarySearch.binarySearch(id, Integer.parseInt(numString)) String output if (index >= 0) output = "The student's name is " + name[index] + "." else output = "ERROR: ID number not found." JOptionPane.showMessageDialog(null, output) } }...
View Full Document

This note was uploaded on 04/10/2008 for the course ENGR 131 taught by Professor Xiaowei during the Spring '07 term at Case Western.

Ask a homework question - tutors are online