Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 17 of 17

Thread: java programing two arrays

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Location
    Namibia , Swakopmund
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default java programing two arrays

    Given the followning two arrays English{"food","hello","phone","house","car"} wambo={"oikulya","ongeipi","ongodi","eumbo","otuwa "} Write a java program that will ask for the Word in english and returns its equivalant in wambo if it exist in array english


  2. #2
    Junior Member
    Join Date
    Sep 2013
    Posts
    18
    Thanks
    3
    Thanked 3 Times in 1 Post

    Default Re: java programing two arrays

    Why not try having a go of it yourself?

    This is a very easy problem. First you'd need to construct both arrays and assign values to the indices. Then you'd need to prompt the user for the word in English. Then, store the input in a String. Loop through the array and see if the string matches any value stored in the English array. When it gets a match, print that same index value in wambo using the toString method.

    I don't know a lot about java, but I am pretty sure what I just explained would work. Now, have a go at actually trying to write that program.

  3. The Following 3 Users Say Thank You to Hisma For This Useful Post:

    jps (September 17th, 2013), mstabosz (September 19th, 2013), PhHein (September 17th, 2013)

  4. #3
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: java programing two arrays

    Spot on, Hisma.

  5. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: java programing two arrays

    Your instructions were to start a thread and ask a question.
    "Write a program" (aka do my homework for me) is not a question

  6. The Following User Says Thank You to jps For This Useful Post:

    mstabosz (September 17th, 2013)

  7. #5
    Junior Member
    Join Date
    Sep 2013
    Location
    Namibia , Swakopmund
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: java programing two arrays

    jus give me an outline of how the program shud be like i have no clue

  8. #6
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: java programing two arrays

    Quote Originally Posted by johnngolombe View Post
    jus give me an outline of how the program shud be like i have no clue
    See post #2

  9. #7
    Junior Member
    Join Date
    Sep 2013
    Location
    Namibia , Swakopmund
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: java programing two arrays

    u dnt seen 2 be helpin

  10. #8
    Junior Member
    Join Date
    Nov 2012
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: java programing two arrays

    This problem is not hard at all. Just think logically what you need to do. First you need to assign the two or more arrays their values. Secondly you would need to prompt the user for a word in English then compare that word to your English array then use that spot in the English array to get the word in the other language. It should take maybe 20-30 lines max

  11. #9
    Junior Member
    Join Date
    Sep 2013
    Location
    Namibia , Swakopmund
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: java programing two arrays

    this is what:
    1 int index = java.util.Arrays.asList(english).indexOf("food", "hello", "phone", "house", "car");
    2
    3 if(index<0)System.out.println("No wambo equivalent");
    4
    5 else
    6
    7 System.out.println(wambo ["oikulya", "ongeipi", "ongodi", "eumbo", "otuwa"]);
    what did i do wrong or leave out?

  12. #10
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: java programing two arrays

    You seem stuck on more than just doing your homework. Here are some links that may help you:
    How to help yourself get help
    The problem with spoonfeeding

    what did i do wrong or leave out?
    It looks incomplete

  13. #11
    Member
    Join Date
    May 2013
    Posts
    106
    My Mood
    Amused
    Thanks
    16
    Thanked 9 Times in 9 Posts

    Default Re: java programing two arrays

    Johnngolombe, you need to understand a few things first.

    Do you understand the concept of the index of arrays? For example, if your two arrays were named English ad Wambo as you showed us:

    English={"food","hello","phone","house","car"}
    Wambo={"oikulya","ongeipi","ongodi","eumbo","otuwa "}

    Could you tell me what is the index of the word "phone" in the English array?
    Could you tell me what Wambo[3] is?
    If I wrote this code:

    int index = 2;
     
    System.out.println(English[index]);
    System.out.println(Wambo[index]);

    Could you tell me the output of that code? Don't copy it into a compiler and run it yourself.

    Secondly, do you know how to compare strings? There are functions in the String class that compare strings. Given this code:

    String myName = "John Jacob Jingleheimer Schmidt";
    String hisName = "John Jacob Jingleheimer Schmidt";
     
    if(   )
        System.out.println("His name is my name too!");

    Do you know what code to put in the if statement to make that line print out?

  14. #12
    Member
    Join Date
    May 2013
    Posts
    106
    My Mood
    Amused
    Thanks
    16
    Thanked 9 Times in 9 Posts

    Default Re: java programing two arrays

    You know, I put a lot of effort into my previous response (dated September 17th at 4:06 PM), and neither Johngolombe nor that guy Rucy who is obviously in the same class have bothered to look or respond. Am I being petty being annoyed by that?

  15. #13
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: java programing two arrays

    You should get used to it. It is amazing the number people who ignore the very good advice they get. Mostly due to their lack of knowledge. If they do not understand something they simply ignore it rather than asking for clarification. Or they continue to whine in the hope someone will just give them a fully coded solution.
    Improving the world one idiot at a time!

  16. #14
    Member
    Join Date
    May 2013
    Posts
    106
    My Mood
    Amused
    Thanks
    16
    Thanked 9 Times in 9 Posts

    Default Re: java programing two arrays

    Well I've only been a contributing member (guy who answers questions instead of just asking my own) for a few weeks. I imagine I'll be a burnt out ball of cynicism and bitterness by November.

    Does it usually get worse this time of year? The new school year is starting (at least here in the U.S.; I dunno how it works everywhere else) so I guess there's a lot of newbies out there.

  17. #15
    Junior Member
    Join Date
    Sep 2013
    Posts
    18
    Thanks
    3
    Thanked 3 Times in 1 Post

    Default Re: java programing two arrays

    yeah, it seems folks just want people to do their work for them. I can see why the trend is not to spoonfeed or bend over backwards for people.

  18. #16
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: java programing two arrays

    Au contraire!

    I am more than willing to bend over backwards for people providing they put in the effort (post code, error messages, ask specific questions etc).
    Improving the world one idiot at a time!

  19. #17
    Junior Member
    Join Date
    Sep 2013
    Posts
    8
    My Mood
    Amazed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: java programing two arrays

    is fine we already get the solution

Similar Threads

  1. JAva programing
    By swapnilrjn in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 19th, 2013, 03:57 PM
  2. Java programing style
    By maple1100 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 5th, 2013, 05:24 PM
  3. Introduction to programing class. I am stuck on my assignment arrays.
    By dozindave in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 18th, 2012, 10:31 PM
  4. Java programing help plz!
    By qazwsx in forum Java Theory & Questions
    Replies: 1
    Last Post: July 21st, 2012, 07:01 PM
  5. java thread programing.
    By parisa in forum Member Introductions
    Replies: 1
    Last Post: July 26th, 2011, 01:38 PM