![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Oct 2004
Posts: 31
Rep Power: 0
![]() |
help needed
i want to know how to search an array.
for example say when user types 'A' displays 4 'B' display 3 'C' display 2 'D' display 1 like that..the task should be implemented using arrays..both the grades and points should be stored in arrays and search(when user type A it should search 4 from points array.. could somebody help |
|
|
|
|
|
#2 |
|
Professional Programmer
|
did ya try doing it yourself?
write out in english what steps you need to take and then code it. |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Feb 2005
Location: Singapore
Posts: 13
Rep Power: 0
![]() |
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;
}
}
}
} |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|