EP MINDTAPV2.0 FOR MALIK'S C++ PROGRAMM
8th Edition
ISBN: 9780357425299
Author: Malik
Publisher: CENGAGE CO
expand_more
expand_more
format_list_bulleted
Question
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.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents 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
Chapter 8 Solutions
EP MINDTAPV2.0 FOR MALIK'S C++ PROGRAMM
Ch. 8 - Mark the following statements as true or false. A...Ch. 8 - Consider the following declaration: (1,2) double...Ch. 8 - Identify error(s), if any, in the following array...Ch. 8 - Determine whether the following array declarations...Ch. 8 - Prob. 5SACh. 8 - Write C+ + statement(s) to do the following: (1,...Ch. 8 - Prob. 7SACh. 8 - Prob. 8SACh. 8 - Prob. 9SACh. 8 - Prob. 10SA
Ch. 8 - Prob. 11SACh. 8 - Correct the following code so that it correctly...Ch. 8 - Prob. 13SACh. 8 - Suppose that points is an array of 10 components...Ch. 8 - Determine whether the following array declarations...Ch. 8 - Prob. 17SACh. 8 - Prob. 19SACh. 8 - Prob. 1PECh. 8 - Prob. 2PECh. 8 - Write a C+ + function, lastLargestIndex that takes...Ch. 8 - Write a program that reads a file consisting of...Ch. 8 - Prob. 6PECh. 8 - Write a program that allows the user to enter the...Ch. 8 - Write a program that uses a two-dimensional array...Ch. 8 - Prob. 12PECh. 8 - Write a program to calculate students average test...
Knowledge Booster
Similar questions
- Write a program to help your instructor calculate the highest and the lowest grade in the final exam of his/her CSCI250 section. Your program should ask the instructor to enter the number of students and then the grade for every student. The grades should be stored in an array. Then the program should find and display the highest and the lowest grade in the array as shown the sample run below. Sample run 1: Enter the number of Students: 5 Enter grade for student 1: 80.5 Enter grade for student 2: 35 Enter grade for student 3: 75.5 Enter grade for student 4: 90 Enter grade for student 5: 63.4 The highest grade is 90 The lowest grade is 35.0 Sample run 2: Enter the number of Students: 3 Enter grade for student 1: 80 Enter grade for student 2: 60 Enter grade for student 3: 80 The highest grade is 80 The lowest grade is 60arrow_forwardUSE PYTHON A local zoo wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Stores this information in a two dimensional 3 × 7 array, where each row represents a different monkey and each column represents a different day of the week. First let the user input the data for each monkey then it should create a report that includes the following information: =>Average amount of food eaten by each monkey for the whole week. =>The least amount of food eaten during the week by any one monkey. =>The greatest amount of food eaten during the week by any one monkey.arrow_forwardJAVA Your teacher has created two arrays, each holding the results of tests, say Test 1 and Test 2. You need to create a new array which holds the averages of these two tests. You may assume that the first element of the first test array refers to the student who also has the grade in the first element of the second test, and the last element in each array are the grades the last student earned for each test. All students received grades for both tests, meaning both test arrays are of the same length. Complete the method, named makeAverage, in the class named Grades.java. There are two parameters to this method: the first is the integer array representing the grades of the first test, and the second is the array containing the grades of the second test. The new average array should be returned by the method. The grades should be treated as double variables. For example, consider the test grades for the five students in the following arrays: [ 87 ] [ 91 ] [ 76 ] [ 76 ] [ 94 ]…arrow_forward
- The array index can be any integer less than the array size… TRUE OR FALSEarrow_forward1. Create a new project and name it fa3_- 2. Use arrays in writing this program. 3. Write a program that computes for the median of a one-dimensional array. The median is computed as follows: a. If the number of elements is odd, the median is the middle element. in 180 b. If the number of elements is even, the median is the average of the two middle elements. 7 4. The array size can range from 3-10 only. 5. Take note that the elements should be in ascending order before computing for the median. SAMPLE OUTPUT: Desired number of elements: 3 6. Provide all possible validations. 7. See sample output below. Enter 3 elements: 5 The median is 7. Try Again [YIN]? Yarrow_forwardWrite a program to help your instructor calculate the highest and the lowest grade in the final exam of his/her CSC1250 section. Your program should ask the instructor to enter the number of students and then the grade for every student. The grades should be stored in an array. Then the program should find and display the highest and the lowest grade in the array as shown the sample run below. Sample run 1: Enter the number of Students: 5 Enter grade for student l: 80.5 Enter grade for student 2: 35 Enter grade for student 3: 75.5 Using java Enter grade for student 4: 90 Enter grade for student 5: 63.4 The highest grade is 90 The lowest grade is 35.0 Sample run 2: Enter the number of Students: 3 Enter grade for student 1: 80 Enter grade for student 2: 60 Enter grade for student 3: 80 The highest grade is 80 The lowest grade is 60arrow_forward
- True or False. A simple variable, also called a scalar variable, is one that is unrelated to any other variable in the computer’s internal memory. The bubble sort algorithm gets its name from the fact that as the larger values drop to the bottom of the array, the smaller values rise, like bubbles, to the top. Programmers use arrays to temporarily store related data in the internal memory of the computer. Different variables in the same array may have different data types. The elements in an array can be used just like any other variables. When an array is sorted in ascending order, the first element contains the largest value and the last element contains the smallest value. When passing an array by reference in C++, you do not include the address-of operator before the formal parameter’s name in the function header. You distinguish one variable in a one-dimensional array from another variable in the same array using a unique integer,…arrow_forwarddo both tasksarrow_forwardWrite the code that converts your student number to binary values. Just after calculating each digit of the binary value, dynamically add it to the array that you expand with each step. After completing the calculation and adding to the dynamic array, list the binary code in the dynamic array correctly. Perform the necessary coding with the C programming language.arrow_forward
- The index type of an array may be any kind of data. Do you believe this to be true?arrow_forwardMultiple Frequencies. In the last assignment, we calculated the frequency ofa coin flip. This required us to have two separate variables, which we used to record the numberof heads and tails. Now that we know about arrays, we can track the frequency of all numbers ina randomly generated sequence.For this program, you will ask the user to provide a range of values (from 1 to that number,inclusive) and how long of a number sequence you want to generate using that number range.You will then generate and save the sequence in an array. After that, you will count the numberof times each number occurs in the sequence, and print the frequency of each number.Hints: You can use multiple arrays for this assignment. One array should hold thenumber sequence, and another could keep track of the frequencies of each number.Sample Output #1:What’s the highest number you want to generate?: 5How long of a number sequence do you want to generate?: 10Okay, we’ll generate 10 number(s) ranging from 1 to 5!1,…arrow_forwardBookworm boolkstores announced a competition running over four weeks for their three branches. The branch with the highest sales per week will receive a surprise for that week. programmer are requested to write a program to keep record of the number of books sold per week in each of the three branches over this period of four weeks. The (incomplete) program below inputs the respective number of books sold and stores it in a two-dimensional array called sales, with four rows and three columns. The program then displays for each week, the highest number of books sold. You as a Here is an example of the input data for the program: Bookworm Bookworm Bookworm South West North Week I Week 2 Week 3 Week 4 T00 120 T22 TUI 103 96 T19 106 99 102 And the corresponding output: The highest sales in week 1 were 120 books. The highest sales in week 2 were 122 books. The highest sales in week 3 were 119 books The highest sales in week 4 were 106 books. Use the declarations in the (incomplete) program…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT