Question: Complete the following program so that it computes and writes out the two largest elements in the array. Use only one loop and don't change
Complete the following program so that it computes and writes out the two largest elements in the array. Use only one loop and don't change any elements of the array.
import java.io.* ; class TwoLargest { public static void main ( String[] args ) { int[] data = {3, 1, 5, 7, 4, 12, -3, 8, -2}; // declare and initialize variables for the two largest // compute the two largest for ( int index= ; index < data.length; index++) { } // write out the two largest System.out.println( ); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
