C++ Programming: From Problem Analysis To Program Design, Loose-leaf Version
C++ Programming: From Problem Analysis To Program Design, Loose-leaf Version
8th Edition
ISBN: 9781337684392
Author: Malik, D. S.
Publisher: Cengage Learning
Question
Book Icon
Chapter 8, Problem 12PE
Program Plan Intro

Program Plan:

  • Include the header files as per code requirement.
  • Define the function read_data() having required parameters such as an array of string to store player names, a 2D array of doubles to store miles run by each player on each day of the week and an integer is defined to store number of players or number of rows.
  • Declare and initialize required constant variables to store number of players and number of days in a week which will be number of rows and columns of the 2D array to store the number of miles run each day of a week by each player.
  • Get the player’s name and store it into the array player_Names at current index.
  • Define the function compute_average() to compute the average of miles.
  • Define the function disp_average () to display the average of miles
  • Print the player’s name from the array player_Names, total miles and average miles each day from array total_n_avg_miles.
  • Declare required arrays to store player names, number of miles run each day by each player, and total miles and average miles run each day.
  • Call the main function and call all three methods.
  • Display the output on console.

Program Description:

The main purpose of the program is to read the data from the input file and compute the total miles run by each runner and average number of miles run each day and display the names of runner along with their toal miles and average number of miles.

Blurred answer
Students have asked these similar questions
InC++ Jason, Samantha, Ravi, Sheila, and Ankit are preparing for an upcoming marathon. Each day of the week, they run a certain number of miles and write them into a notebook. At the end of the week, they would like to know the number of miles run each day, the total miles for the week, and the average miles run each day. Write a program to help them analyze their data. Your program must contain parallel arrays: an array to store the names of the runners and a two-dimensional array of five rows and seven columns to store the number of miles run by each runner each day. Furthermore, your program must contain at least the following functions: a function to read and store the runners’ names and the numbers of miles run each day; a function to find the total miles run by each runner and the average number of miles run each day; and a function to output the results (You may assume that the input data is stored in a file and each line of data is in the following form: runnername milesday1…
Jason, Sam, Beth, James, and Larry are preparing for an upcoming marathon. Each day of the week, they run acertain number of miles and write them into a notebook. At the end of the week, they would like to know thenumber of miles run each day, the total miles for the week, and average miles run each day. Write a program tohelp them analyze their data. Your program must contain parallel arrays: an array to store the names of therunners and a two-dimensional array of five rows and seven columns to store the number of miles run by eachrunner each day. Furthermore, your program must contain at least the following functions:a. A function to read and store the runner’s names and the numbers of miles run each day;b. A function to find the total miles run by each runner and the average number of miles run each day;c. A function to output the results. Assume that the input data is stored in a file and each line of data is in the following form:runnerName milesDay1 milesDay2 milesDay3 milesDay4…
Problem2 Write a program that display the position of a given element in an array. You should print the index (i.e. the position) of the element. If the element appears more than one time than you should print all its positions. The size of the array should be entered by the user. If the element does not occur then you should display element not found. Sample1: Enter the size of the array: 5 Enter an array of size 5: 44 5 13 44 67 Enter the element to find: 44 44 is found at position 44 is found at position 44 occurs 2 time(s) Sample2: Enter the size of the array: 4 Enter an array of size 4: 12 150 17 20 Enter the element: 18 18 is not found
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT