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 Also note: If the submitted code tries to access an invalid array element, such as runTimes[9] for a 5-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message. 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 */ }}

Question

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

Also note: If the submitted code tries to access an invalid array element, such as runTimes[9] for a 5-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message.

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 */

}
}

 

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: Write a python code to create a list of books with its corresponding ISBN number. Ask the user to in...

A: Python program to search the book from the list. create a list of books with its corresponding ISBN...

Q: Write an array java program asking the user how many integer numbers to read in and create a one dim...

A: Java does not have the inline function. When the program code located in a public class, the user ca...

Q: When is a constructor called? When an object is destroyed When it is called explicitly with the ...

A: Since there are multiple questions, the answer is provided only for few questions.

Q: What are the advantages and disadvantages of passing parameters in a C program instead of using a gl...

A: Parameter passing allows the user to use value of local variables which were declared within main pr...

Q: Trace the execution of the following fragment.       int m = 10, n = 5;       int *mp, *np;       mp...

A: After compiling the code, it will generate the errors as the printf statement is not correctly writt...

Q: Write the JavaScript code for the function validateUsernameLength that will checkwhether the usernam...

A: index.html &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;JavaScript ...

Q: Convert the algorithm provided into C source code: The OUL Wagner Theater has a three tiered pricing...

A: #include&lt;stdio.h&gt; //compute sales double calcSales(char s, int st, int rt) { double sales = 0...

Q: Construct the truth table for the following KB: A V B =&gt; C C ^ B

A: Truth table: A truth table is a breakdown of a commonsense characteristic by way of listing all pos...

Q: C++ (Tic-Tac-Toe) Write a program that allows two players to play the tic- tac-toe game. Your progra...

A: Program: #include &lt;iostream&gt; #include &lt;iomanip&gt; using namespace std; class ticTacToe{ pr...

Q: When would you be most likely to use an abstract class? when you need to derive a class from Objec...

A: An abstract class is most likely to be used when a superclass is required that should be not be inst...

Q: Use the stack-based algorithm for converting a postfix expression into an expression tree for the po...

A: Below is the Stack-based algorithm which is used to build the expression tree from postfix expressio...

Q: Write an algorithm that read 5 distinct integers and displays the largest value in java. Assume the ...

A: Programming instructions (algorithm): First, take the input of 5 distinct integers from the user in...

Q: how do you copy and paste a froumla from a cell to a range of cells in Excel?

A: Copy and paste a formula from a cell to a range of cells: Click on the cell in which you have alrea...

Q: What is the difference between a static website and a dynamic one?

A: Static Website – A simple website created using an HTML and released to the web server is a static w...

Q: //1. Declare an array arr1 and initialize it to 1, 2, 3, 4, 5, 6, 7, 8, and 9//2. Declare another ar...

A: //definition of "Test" class public class Test {     //definition of main method     public static v...

Q: in von neumann architecture , external bus is for data memory only

A: Von neumann architecture: The von neumann architecture by the mathematician Jhon von neumann conceiv...

Q: - Is it surprising to you that a relatively small company like Sunny Delight could end up with so ma...

A: No. It is not at all surprising that even a small company like Sunny Delight could end up with so ma...

Q: Write a program. a. Request an integer dollar amount from the console. b. Calculate how many forever...

A: The below given C++ program will obey the following rubrics: Importing necessary header files. In m...

Q: java, SumOfInputs

A: Program: //include the header file  import java.util.Scanner;    //definition of class  public class...

Q: Perform the following logical operations, assuming a nine-bit cell:a)                           010 ...

A: Negative and zero bits:   The negative bit “N” is used to detect the negative result, and “Z” bit is...

Q: Write the program that does the following:   Prompts for and reads in several positive integer valu...

A: The below given C++ program code will obey the following rubrics: Including necessary header files....

Q: write a python program that asks the user to enter a distance in kilometers, and then convert that d...

A: Following is the python program that takes input the distance in kilometers from the user and conver...

Q: Write a jQuery code that will check whether the text-box for username is blank. If it is blank, an a...

A: Note: We are authorized to answer only one question at a time. Since you have asked more than one qu...

Q: create a program in c that mimics the following dice game: A player rolls two dice. Each die has six...

A: There are two different questions was asked. The below answer is provided for the first question. If...

Q: // // Write a function that calculates the amount of money a person would earn over // a period of y...

A: Program plan: Define a function named totalEarned() with years as a parameter. Declare and initiali...

Q: in Java, Write a program that reads student scores, gets the best score, and then assigns grades bas...

A: Java program to determine the grade of a student corresponding to the score. Prompt user to enter t...

Q: Write a program that takes in two positive integer inputs, m and n, and prints out a neatly formatte...

A: C++ program to print a neatly formatted table of user-entered size m* n. This table contains element...

Q: In C, Write a statement that terminates the current loop when the value of the int variables x. and ...

A: //define main function int main() {     //declare the required variables     int x,y;         //prom...

Q: Which of the following is NOT part of a Layer 3 IPv4 Packet? A. Protocol B. Source MAC Address C. De...

A: The OSI Model is a seven-layer Networking model. The third layer of the OSI model is Network Layer. ...

Q: In C code, Given an int variable count that has already been declared, write a for loop that prints ...

A: The C program and its approach is given below: - Approach: - Declaring the necessary headers. Defin...

Q: Java

A: The below given java program will obey the following rubrics: Importing essential header files. Dec...

Q: Write a program that presents a menu to user to choose a letter from the menu or type “Q” to quit. M...

A: As you didn't mentioned the programming language, i am using C++ to write the program.   Program cod...

Q: What is the worse-case complexity scenario for the following snippets of code? Please show the break...

A: Since in both loops, the increment is constant and the range is 0 to n (in general), so the complexi...

Q: Describe the purpose of shell scripts? Provide one example to reflect the use of variables, construc...

A: Purpose of shell scripts: A text file which includes a set of commands for a UNIX-based Operating S...

Q: Programing in C Write a program that calculates the average grade of a class. 1. You should ask the ...

A: Below is the C program and its approach to calculating the average grade of a class: - Approach: - ...

Q: In C code, Write a for loop that prints in ascending order all the positive multiples of 5 that are ...

A: The C program and its approach are given below: - Approach: - Importing the header file. The main()...

Q: Programing in C

A: Note: Comments have been added to the source code itself to have a better understanding of the code....

Q: Figure Q3.13 The Ch03_VENDINGCO database tables Table Name: BOOTH    BOOTH _PRODUCT BOOTH _PRI...

A: The results of the two tables can be combined and this is done with the help of the UNION operator a...

Q: Lab 3: Normalization Assignment: Problem #11 from Chapter #6. (Be sure to note that this is PROBLEM ...

A: The relation schema for the table structure is given below, CHARTER (CHAR_TRIP, CHAR_DATE, CHAR_CITY...

Q: How do I use smartart in Microsoft

A:   The primary use of Smart art is to provide a more graphical and visual form of certain specific pa...

Q: Write a C++ program that allows the user to input a temperature value in Celsius and prints the corr...

A: Note: Comments have been added in the source code itself to have a better understanding of the code....

Q: Write a program to swap two numbers without using third variable. Please do this in C++.

A: Program approach – Include the essential header files. Define the main method. Prompt user to enter...

Q: Use the format SEEMMMM. All digits are decimal. The exponent is stored excess-50. The implied decima...

A: a. 28543 = 0.28543 x 10^5 hence the floating point representation is &lt;sign&gt;&lt;exponent in ex...

Q: Assignment: Problem #7 from Chapter 4 of the textbook. The case study is United Helpers. With the us...

A:   [ Note: We’ll answer the first three subparts of the question since the exact one wasn’t specified...

Q: 1. Write a Python program to: ask the user to enter the price of an item. Note: use a while loop to ...

A: Program code: # Prompt user to enter the price of the item p = float(input("Enter the price of the i...

Q: A software company sells a package that retails for $99. Quantity discounts are given according to t...

A: Program: #get the input from the user num = float(input("Enter the number of packages purchased: "))...

Q: Programming in C Since communication channels are often noisy, numerous ways have been devised to en...

A: A C program for the given criteria is as follows, File name: “main.c” #include&lt;stdio.h&gt; #inclu...

Q: How can we use the Big Data/ Text Information Extraction technologies in multi-lingual datasets?

A: The objective of multilingual toolkit is performing many tasks in the extraction of information and ...

Q: (a) Which Gradient Descent algorithm (stochastic, batch, mini batch)will reach the vicinity of the o...

A: (A) The stochastic gradient descent will reach the vicinity of the optimal solution the fastest as i...

Q: 35) Assuming seven-bit two’s complement binary representation, write the bit patterns for the follow...

A: a. -73: Step 1: Convert the decimal number to binary number. Step 2: The binary equivalent number fo...