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

use java finfish this problem Program Description: This program will prompt user

ID: 3763699 • Letter: U

Question

      use java finfish this problem                            
 Program Description: 
                          This program will prompt user to input         *               integers into an array with pre-determined bounds. The         *               user will continue to input integers until either the user         *               enters the sentinel value or the array becomes full. In both         *               cases the inputted array will be displayed for the user, with         *               the execption that if the array is full, it will be displayed         *               along with the results. 
  BEGIN EmptyArrayInsert         *    Initialize count = 0         *    Prompt user for the size of the array         *    WHILE (size is not 0)         *               call method to insert numbers into the array         *       clear the screen         *       cal method to display contents of the array         *       prompt user for size of the next array or 0 to quit         *    END WHILE         * END EmptyArrayInsert 

Explanation / Answer

import java.io.*;
import java.util.*;
class EmptyArrayInsert
{
//Reads an array of elements, for given size or till the array is full.
public static void InsertElements(int Array[], int size)
{
Scanner sc = new Scanner(System.in);
for(int i = 0; i < size && i < Array.length; i++)
Array[i] = sc.nextInt();
}
public static void main(String[] args) throws IOException
{
int size = 0;
int[] Array = new int[5];
Scanner sc = new Scanner(System.in);
do
{
System.out.print("Enter the size of array: ");   //Reads the size of array.
size = sc.nextInt();              
if(size != 0)   //If size is not 0.
{
InsertElements(Array, size);   //Call the function to read numbers.
}
if(size > Array.length)       //If the size if greater than the size of array.
{
System.out.println("Array index out of bounds...");   //Print a relavent message.
size = Array.length;           //And set the size to Array.length.
}
for(int i = 0; i < size; i++)   //Print the elements in the array.
System.out.print(Array[i]+" ");
System.out.println();
}while(size != 0);
}
}