Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By jim829

Thread: Im New, Help?

  1. #1
    Join Date
    Feb 2015
    Posts
    1
    Rep Power
    0

    Default Im New, Help?

    Hi, im new to programming and ive been given a task to do however I have no ide how to do it, can anyone help me out?

    This is it:
    Write a class called Exercise1 which contains a static method min that finds the minimum value in an array of integers. Make sure that the method works even if the array contains only one element. Write an Exception class that should be thrown if the array does not contain any elements. Note the min method is static so that it can be called by other classes as follows:

    Java Code:
    public static void main(String[] args) {
    int[] theArray = new int[10];
    // initialise array
    int result = Exercise1.min(theArray);
    // Where the class Exercise1
    // contains the min method
    }
    Complete the main method above with appropriate try and catch blocks to test that the min method works correctly in all scenarios.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: Im New, Help?

    Take a piece of paper and write down about 5 different integers (but not in any specific order). Then go thru the list and determine how you would arrive at the minimum value. You will need other variables and a comparison. How you do it on paper is almost exactly how you do it in a program.

    Regards,
    Jim
    ssk2659 likes this.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

    Default Re: Im New, Help?

    Quote Originally Posted by notagoodprogrammer View Post
    Im New, Help?
    Please go through the Forum Rules, paricularly the third paragraph.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

    Default Re: Im New, Help?

    By the way, in how many forums have you posted this?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •