1. Engineering
  2. Computer Science
  3. hi i am given this piece of code and an...

Question: hi i am given this piece of code and an...

Question details

Hi, I am given this piece of code and an input file, numbers.txt which contains 100 integers. I need to find the min integer and max integer from the input file. How do I call the input file, "numbers.txt"? Do I replace infileName with numbers.txt? I am so confused, please help.

// STEP #1: OPEN THE INPUT FILE AND COMPUTE THE MIN AND MAX. NO OUTPUT STATMENTS ALLOWED
                Scanner infile = new Scanner( new File(infileName) );
                int min,max;
                min=max=infile.nextInt(); // WE ASSUME INPUT FILE HAS AT LEAST ONE VALUE
                while ( infile.hasNextInt() )
                {
                        // YOUR CODE HERE FIND THE MIN AND MAX VALUES OF THE FILE
                        // USING THE LEAST POSSIBLE NUMBER OF COMPARISONS
                        // ASSIGN CORRECT VALUES INTO min & max INTHIS LOOP. 
                        // MY CODE BELOW WILL FORMAT THEM TO THE SCREEN
                        // DO NOT WRITE ANY OUTPUT TO THE SCREEN
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution