Write three statements to print the first three elements of array runTimes. Follow each statement with a newline. Ex: If runTime = {800, 775, 790, 805, 808}, print:
800
775
790
import java.util.Scanner;
public class PrintRunTimes {
public static void main (
String [] args) {
Scanner scnr = new Scanner(System.in);
final int NUM_ELEMENTS = 5;
int [] runTimes = new int[NUM_ELEMENTS];
int i;
for (i = 0; i < runTimes.length; ++i) {
runTimes[i] = scnr.nextInt();
}
/* Your solution goes here */
// Populate array
runTimes[0] = 800;
runTimes[1] = 775;
runTimes[2] = 790;
runTimes[3] = 805;
runTimes[4] = 808;
for ( i = 0 ; i < 3; i++){
System.out.println(runTimes[i]);}
}
}
Testing with inputs: 800 775 790 805 808
Your output
800
775
790
Testing with inputs: 10 25 -10 20 -15
Output differs. See highlights below.
Your output
800
775
790
Expected output
10
25
-10