1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vesna_86 [32]
2 years ago
12

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
Note: These activities will test the code with different test values. This activity will perform two tests, both with a 5-element array (int runTimes[5]). See "How to Use zyBooks".
Also note: If the submitted code tries to access an invalid array element, such as runTime[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.
#include
using namespace std;
int main() {
const int NUM_ELEMENTS = 5;
int runTimes[NUM_ELEMENTS];
int i;
for (i = 0; i < NUM_ELEMENTS; ++i) {
cin >> runTimes[i];
}
/* Your solution goes here */
return 0;
}
Please help me with this problem using c++.

Computers and Technology
1 answer:
yawa3891 [41]2 years ago
8 0

Answer:

Following are the code to this question:

for (i = 0; i <3; ++i)//defining loop to print value

{

cout<<runTimes[i]<<endl;//print value

}

Explanation:

Full program code to this question:

#include<iostream>//defining header file

using namespace std;

int main() //defining main method

{

const int NUM_ELEMENTS = 5;//defining const integer variable

int runTimes[NUM_ELEMENTS]; //defining integer array

int i;//defining integer variable

for (i = 0; i < NUM_ELEMENTS; ++i)//defining loop to input value

{

cin >> runTimes[i];//input value  

}

cout<<"print three elements value of array: "<<endl;

for (i = 0; i <3; ++i)//defining loop to print value

{

cout<<runTimes[i]<<endl;//print value

}

return 0;

}

Output:

Please find the attachment.

Description:

  • In the above code, an integer const variable "NUM_ELEMENTS" is declared, that assign value "5" which is array size, in the next step, an array "runTimes" is declared.
  • In the next step, for loop is used, that uses an integer variable "i", which is used to input all array elements.
  • In the next line, another for loop is used, which uses "i" variable, which starts from 0 and ends when its value less than 3, inside the loop print method, used that prints 3 array elements.  

You might be interested in
The changing of values for an object through a system is represented by the _____. (Points : 6) communication diagram
Fed [463]

Answer:

The correct option is communication diagram

Explanation:

The communication diagram represents the change of values for an item by a system.

A communication diagram is an expansion of the diagram of objects showing the objects together with the texts traveling from one to another. Besides the connections between objects, the communication diagram demonstrates the messages that the objects send to one another.

The correct option is a) communication diagram

8 0
2 years ago
A hotel salesperson enters sales in a text file. Each line contains the following, separated by semicolons: the name of the clie
timama [110]

Answer:

see explaination

Explanation:

Java code

//Header file section

import java.util.Scanner;

import java.io.*;

//main class

public class SalesTestDemo

{

//main method

public static void main(String[] args) throws IOException

{

String inFile;

String line;

double total = 0;

Scanner scn = new Scanner(System.in);

//Read input file name

System.out.print("Enter input file Name: ");

inFile = scn.nextLine();

FileReader fr = new FileReader(new File(inFile));

BufferedReader br = new BufferedReader(fr);

System.out.println("Name \t\tService_Sold \tAmount \tEvent Date");

System.out.println("=====================================================");

line = br.readLine();

//Each line contains the following, separated by semicolons:

//The name of the client, the service sold

//(such as Dinner, Conference, Lodging, and so on)

while(line != null)

{

String temp[] = line.split(";");

for(int i = 0; i < temp.length; i++)

{

System.out.print(temp[i]+"\t");

if(i == 1)

System.out.print("\t");

}

//Calculate total amount for each service category

total += Double.parseDouble(temp[2]);

System.out.println();

line = br.readLine();

}

//Display total amount

System.out.println("\nTotal amount for each service category: "+total);

}

}

inputSale.txt:

Peter;Dinner;1500;30/03/2016

Bill;Conference;100.00;29/03/2016

Scott;Lodging;1200;29/03/2016

Output:

Enter input file Name: inputSale.txt

Name Service_Sold Amount Event Date

=====================================================

Peter Dinner 1500 30/03/2016

Bill Conference 100.00 29/03/2016

Scott Lodging 1200 29/03/2016

Total amount for each service category: 2800.0

3 0
3 years ago
Write the interface (.h file) of a class Counter containing: A data member counter of type int. A data member named counterID of
OlgaM077 [116]

Explanation:

See the attached image for The interface (.h file) of a class Counter

8 0
3 years ago
List 5 items you should keep in mind when developing an app:
Mrac [35]

Answer:

  1. Agree on aims concerning the application.
  2. Read your end users.
  3. Take your IT partners toward the conversations in the beginning.
  4. Program for various announcements.
  5. Choose the technology which you know and will be able to continue.

Explanation:

You should always keep the above five points while developing an app. You should keep your goals in mind that what kind of app you are going to develop and you are taking surveys from end users that what they want after some time in different cycles. Your team should discuss your project time by time about the progress of an app. Your project should be a long term and should almost cover all kind of users.



6 0
3 years ago
Most wires are covered in rubber to insulate them and keep people safe from electricity and heat true of false
daser333 [38]

Answer:

I think it is true...

Explanation:

Hope its right

3 0
3 years ago
Other questions:
  • What is a valence orbit?
    13·2 answers
  • Electricity is moved from place to place a long __________​
    14·2 answers
  • 2.27 LAB: Driving costs Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as
    14·2 answers
  • The parameter passing mechanisn used in C is
    5·2 answers
  • What are 2 main differences betweenarrays andstructs?
    7·1 answer
  • Will give brainliest!<br> Who created binary, and does anyone have any idea how?
    13·1 answer
  • What is a device driver​
    13·2 answers
  • Name 4 components of a components system​
    9·1 answer
  • Defination of formula bar​
    14·1 answer
  • to troubleshoot an output component or input device, the first step is to activate the input device that controls the first outp
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!