Results 1 to 2 of 2
  1. #1
    ananasman is offline Member
    Join Date
    Nov 2008
    Posts
    5
    Rep Power
    0

    Default Help with problem

    I need to make a method that gets integer table argument and returns table that has smallest number as the first argument, biggest number second and their average as third. Heres what i have achieved.

    public class Statics {

    public static void main(String[] args) {
    int[] numbers = {60, 10, 8, 4};
    int[] statistics = statics(numbers);

    for (int i = 0; i < statistics.length; i = i + 1) {
    System.out.println(statistics[i]);
    }
    }

    public static int[] statics(int[] numbers) {

    }

    }

  2. #2
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    7

    Smile if (next < current){current = next;}

    Quote Originally Posted by ananasman View Post
    I need to make a method that gets integer table argument and returns table that has smallest number as the first argument, biggest number second and their average as third. Heres what i have achieved.
    Needs basic work....
    Java Code:
    public class Statics {
        //
        public static void main(String[] args) {
            int[] numbers = {60, 10, 8, 4};
            int[] statistics = new int[numbers.length];//
            int nextCandidate = numbers[0];
            // 
            for (int i = 0; i < numbers.length;i++)
            {
                if(numbers[i] > nextCandidate)
                {
                    numbers[i] = nextCandidate;
                }
                else
                {
                    continue;
                }
            }
            System.out.println(nextCandidate);
        }
    }
    This is simple code, contemplation will do more good now than coding.

    Wow, fuschia!
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

Posting Permissions

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