Question: import java.util.*; import java.io.*; public class Lab4 { static final int MAX_CAPACITY = 30; // HARDOCED PLENTY BIG. WE'LL DO TRIM AFTER public static void

import java.util.*; import java.io.*; public class Lab4 { static final int MAX_CAPACITY = 30; // HARDOCED PLENTY BIG. WE'LL DO TRIM AFTER public static void main( String args[] ) throws Exception { if (args.length < 1 ) { System.out.println("usage: $ java Lab3  "); System.exit(0); } int[] arr = new int[ MAX_CAPACITY ]; int count=0; Scanner infile = new Scanner( new File( args[0] ) ); while ( infile.hasNextInt() ) { insertInOrder( arr, count, infile.nextInt() ); ++count; } arr = trimArray( arr, count ); printArray( arr ); // NOTE: NO COUNT PASSED IN }// END MAIN // ############################################################################################################ // MUST USE ENHANCED FOR LOOP IN THIS METHOD // (YOUR TRIM BETTER HAVE BEEN WRITEN CORRECTLY) static void printArray( int[] array ) { // PRINT EACH NUMBER WITH A SPACE AFTER IT System.out.println(); // LEAVE THIS HERE } static int[] trimArray( int[] array, int count ) { return array; // THIS IS NOT CORRECT. YOU MUST REPLACE IT!!!! } // THE CODE IN HERE NOW JUST APPENDS. THIS IS NOT CORRECT static void insertInOrder( int[] arr, int count, int newVal ) { arr[count] = newVal; // THIS IS NOT CORRECT. YOU MUST REPLACE IT!! } }// END LAB #4 

Input file

59 82 29 52 60 44 78 93 22 67 76 54 13 77 94 62 100 27 85 35 68 38 55 26 43

Thank you

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!