lundi 28 septembre 2015

Using arrays to find the largest number between 2 lists

Create a program that randomly generates 5 numbers from 1 to 50, have these print out and then a second array to do the same thing. Have the program determine which is the largest number between the 2???? Okay so this is a question i asked myself and this is probably completely wrong but i tried:

public class FindArray2 
{
    public static void main(String args[]) {
        int[] list = new int[5];
        for (int i = 0; i < 5; i++) {
            list[i] = (int)(Math.random() * 50) + 1;
            System.out.println(list[i]);
        }

    }
    public static double[] ListOne() {
        double[] list = new double[5];
        for (int i = 0; i < 5; i++) {
            list[i] = (int)(Math.random() * 50) + 1;
            System.out.println(list[i]);
        }
        return list;
    }
    public static double[] ListTwo() {
        double[] list = new double[5];
        for (int i = 0; i < 5; i++) {
            list[i] = (int)(Math.random() * 50) + 1;
            System.out.println(list[i]);
        }
        return list;
    }
}

I could use a lot of help




Aucun commentaire:

Enregistrer un commentaire