Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I want to allow the user to enter any number of numbers and have them placed int

ID: 3551488 • Letter: I

Question

I want to allow the user to enter any number of numbers and have them placed into an int array. I have been trying to use the max method but I am certain that I am not doing it right. This is part of a much bigger assignment to manipulate the input in the array with sort and search, but I cant even get the input right to test the array. This is the code I have been trying to use:


import java.util.Scanner;

public class NumbersArray
{
   public static void main(String [] args)
   {
      System.out.print("Enter Numbers with a single space between each number: ");
      Scanner keyboard = new Scanner(System.in);
      int num = keyboard.nextInt();
      while(keyboard.nextInt());
      {
         int num = keyboard.nextInt();
      }
   }
      public static int max(int... num)
      {  
         if (num.length == 0)
         {
            System.out.println("Fatal Error: no values entered.");
         }
      }
      {
         int numbers = num[0];
         for (int i = 1; i < num.length; i++)
            if (arg [i] < largest)
               numbers = arg[i];
         return numbers;
      }
      System.out.println(numbers);
   }
}



Explanation / Answer

i would suggest you to use list for this as array is not good for this type of implementation.
for array you can use this code


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote