Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 19th, 2005, 9:20 PM   #1
kalinga1234
Programmer
 
Join Date: Oct 2004
Posts: 31
Rep Power: 0 kalinga1234 is on a distinguished road
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
kalinga1234 is offline   Reply With Quote
Old Feb 20th, 2005, 1:20 AM   #2
Dizzutch
Professional Programmer
 
Dizzutch's Avatar
 
Join Date: Dec 2004
Location: Worcester, MA
Posts: 441
Rep Power: 4 Dizzutch is on a distinguished road
Send a message via ICQ to Dizzutch Send a message via AIM to Dizzutch Send a message via MSN to Dizzutch Send a message via Yahoo to Dizzutch
did ya try doing it yourself?
write out in english what steps you need to take and then code it.
__________________
naked pictures of you | PFO F@H stats
Dizzutch is offline   Reply With Quote
Old Feb 20th, 2005, 11:21 AM   #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
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:01 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC