Thread: help needed
View Single Post
Old Feb 20th, 2005, 12:21 PM   #3
ian
Newbie
 
Join Date: Feb 2005
Location: Singapore
Posts: 13
Rep Power: 0 ian is on a distinguished road
Re: Help needed.

Okay, here's a simple program to help you out, you'll still have to edit it.
public class arraySearch {
    public static void main(String args[]) {
        char[] alphabets = {'A', 'B', 'C', 'D'};
        int[] numbers = {4, 3, 2, 1};
        
        char userInput;
        //Code to get the user's input
        
        for(int i = 0; i < alphabets.length; i++) {
            if(userInput == alphabets[i]) {
                System.out.println(numbers[i]);
                break;
            }
        }
    }
}
ian is offline   Reply With Quote