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 2 of 2

Thread: beginner-urgent java help needed

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default beginner-urgent java help needed

    Hello, I need some help with a question. I not a very good programmer myself so plese go easy on me. I'm a year 1 student in diploma in Information Technology.

    The question goes like this

    Write an application that will read in people names and their ages. Store them in two arrays. Then do a search of names to find the corresponding age. Follow these steps to write the programme:
    a) Create a class BasicsApp4.java with a main() method
    b) Add a readAge() method
    c) Add a readAges() method
    d) Add a readName() method
    e) Add a readNames() method that will call readName method to store 5 names into an array called nameArray
    f) In the main method, do the followings:
    -Declare ageArray and nameArray with size of 5
    -Call/Invoke readNames() and readAges() methods to read in 5 names and ages
    -Ask the user to enter a name and search for the age
    -Display name and age if found, else display name not found
    -Ask user to enter an age and display all the names with the same age

    Here is what i done so far, I'm not very sure if where i had gone wrong and i did not know how to continue.

    public class BasicApp4 {

    public static void main(String[] args) {
    // TODO Auto-generated method stub
    int[]ageArray = new int[5];
    String[]nameArray = new String[5];

    readName(nameArray);


    }


    private static void readName(String[] nameArray) {
    // TODO Auto-generated method stub
    Scanner sc = new Scanner(System.in);
    System.out.print("Enter name: ");
    name = sc.nextLine();



    }

    private static int readAge(int[] ageArray) {
    // TODO Auto-generated method stub
    Scanner sc = new Scanner(System.in);
    int age;

    do {
    System.out.print("Enter age: ");
    age = sc.nextInt();
    }
    while ((age<0)||(age>100));
    return age;

    }
    private static void readAges(int[] ageArray) {
    // TODO Auto-generated method stub
    for (int i=0; i<ageArray.length; i++){

    }
    ageArray[0]=readAge(null);
    }

    }


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: beginner-urgent java help needed

    Please read the getting help link in my signature, as well as the following: http://www.javaprogrammingforums.com...e-posting.html
    It contains important advice that will help you get help

Similar Threads

  1. URGENT HELP NEEDED WITH ALGORITHM PLEASE! PLEASE! .... THANKS
    By Honours in forum Java Theory & Questions
    Replies: 6
    Last Post: March 13th, 2011, 08:40 PM
  2. urgent help needed
    By nono in forum Member Introductions
    Replies: 2
    Last Post: March 10th, 2011, 11:18 AM
  3. Urgent help needed
    By mohit1007 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: June 23rd, 2010, 09:34 PM
  4. Urgent Help needed with java codes
    By makarov in forum Java Theory & Questions
    Replies: 0
    Last Post: November 13th, 2009, 07:23 AM
  5. Urgent code needed
    By subhvi in forum AWT / Java Swing
    Replies: 4
    Last Post: August 27th, 2009, 12:55 AM

Tags for this Thread