Problem Solving with C++, Student Value Edition plus MyProgrammingLab with Pearson eText -- Access Card Package (9th Edition)
9th Edition
ISBN: 9780133862225
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 7, Problem 4PP
Program Plan Intro
Program Plan:
- Include the appropriate headers into program.
- Declare and define the constant variable “LEN”.
- Declare the appropriate functions.
- Define the “main()” function.
- Declare the array variable “arr[]” in type of double.
- Declare the variables “stdDeviation” and “avg” in type of double.
- Declare the variable “ans” in type of character.
- Using “do…while” loop, prompt the user for array values.
- Call the function “stdDev()” which passes array and size of array and store the result in “stdDeviation”.
- Prompt and get the sentinel value from user.
- Check the loop with condition for sentinel value.
- Return “0” to called function.
- Define the function named “stdDev()” which passes the arguments “arr[]” in type of character and “size” in type of integer.
- Declare and initialize the “sumSquares” in type of “double”.
- Call the function “average()” which passes array and size of array as arguments and stores the result in “avg” variable.
- Using “for” loops, calculate the summation value.
- Return the square root of summation value.
- Define the function named “average()” which passes “arr[]” and “size” as arguments.
- Declare and initialize the “sum” in type of “double”.
- Using “for” loop, calculate the total of array values.
- Return the average of array values.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
We have a list that stores the repeated heart-rate measurements for the same patient over several tests. Each inner-list is a test and for that test, the heart rate is monitored for some time while taking a few measurements. Next, we would like to calculate the average of the measurements for each test.heart_rate = [ [ 72, 75, 71, 73], # resting[ 91, 90, 94, 93], # walking slowly[ 130, 135, 139, 142], # running on treadmill[ 120, 118, 110, 105, 100, 98]] # after minute recoveryIn your code, define a function calculate_average_heart_rates() that accepts the list heart_rate as its only input argument. Inside the function, use nested loops to calculate the average heart rate during each test scenario. This function should return a list that contains the average heart rate values of a patient for the four test scenarios.Write unit tests
There are n professors in a university, and these professors teach m, and there are k classrooms. Find the model that creates the appropriate curriculum with different numbers of n, m, k, write the code and calculate its time complexity
A finite sequence of symbols from a given alphabet will be called a string over the alphabet. A string that consists of a sequence a1, a2, a3, a4, … … … … , an of symbols will be denoted by the juxtaposition a1 a2 a3 a4 … … … … an. Given the strings: u = a2bab2and v = bab2,
Evaluate the following operations for strings:
(i) ԑu(ii) u + v(iii) u(u| v)(iv) v | (v | u)
Chapter 7 Solutions
Problem Solving with C++, Student Value Edition plus MyProgrammingLab with Pearson eText -- Access Card Package (9th Edition)
Ch. 7.1 - Prob. 1STECh. 7.1 - In the array declaration double score(5); state...Ch. 7.1 - Identity any errors in the following array...Ch. 7.1 - What is the output of the following code? char...Ch. 7.1 - What is the output of the following code? double a...Ch. 7.1 - What is the output of the following code? int i,...Ch. 7.1 - Prob. 7STECh. 7.1 - Suppose we expect the elements of the array a to...Ch. 7.1 - Prob. 9STECh. 7.1 - Suppose you have the following array declaration...
Ch. 7.2 - Consider the following function definition: void...Ch. 7.2 - Prob. 12STECh. 7.2 - Write a function definition for a function called...Ch. 7.2 - Consider the following function definition: void...Ch. 7.2 - Insert const before any of the following array...Ch. 7.2 - Write a function named outOfOrder that takes as...Ch. 7.3 - Write a program that will read up to ten...Ch. 7.3 - Write a program that will read up to ten letters...Ch. 7.3 - Following is the declaration for an alternative...Ch. 7.4 - Prob. 20STECh. 7.4 - Write code that will fill the array a (declared...Ch. 7.4 - Prob. 22STECh. 7 - Write a function named firstLast2 that takes as...Ch. 7 - Write a function named countNum2s that takes as...Ch. 7 - Write a function named swapFrontBack that takes as...Ch. 7 - The following code creates a small phone book. An...Ch. 7 - There are three versions of this project. Version...Ch. 7 - Hexadecimal numerals are integers written in base...Ch. 7 - Solution to Programming Project 7.3 Write a...Ch. 7 - Prob. 4PPCh. 7 - Write a program that reads in a list of integers...Ch. 7 - Prob. 6PPCh. 7 - An array can be used to store large integers one...Ch. 7 - Write a program that will read a line of text and...Ch. 7 - Write a program to score five-card poker hands...Ch. 7 - Write a program that will allow two users to play...Ch. 7 - Write a program to assign passengers seats in an...Ch. 7 - Prob. 12PPCh. 7 - The mathematician John Horton Conway invented the...Ch. 7 - Redo (or do for the first time) Programming...Ch. 7 - Redo (or do for the first time) Programming...Ch. 7 - A common memory matching game played by young...Ch. 7 - Your swim school has two swimming instructors,...Ch. 7 - Your swim school has two swimming instructors,...Ch. 7 - Prob. 19PPCh. 7 - The Social Security Administration maintains an...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- An ordinary ruler is a straight piece of wood where distances 0, 1, 2 . . . , N are marked, for some N ≥ 1. A sparse ruler (or simply a ruler ) is an ordinary ruler from which some of the numbers 1, . . . , N −1 may have been deleted. The number of marks on the ruler is its order and the value N is its reach. Here, we will represent a ruler as a Python list of strictly increasing integers starting with 0. For instance [0,1,3,7] is a ruler of order 4 and reach 7. could you please help me answer this in python , the part in bold explains what they mean by ruler herearrow_forwardAn ordinary ruler is a straight piece of wood where distances 0, 1, 2 . . . , N are marked, for some N ≥ 1. A sparse ruler (or simply a ruler ) is an ordinary ruler from which some of the numbers 1, . . . , N −1 may have been deleted. The number of marks on the ruler is its order and the value N is its reach. Here, we will represent a ruler as a Python list of strictly increasing integers starting with 0. For instance [0,1,3,7] is a ruler of order 4 and reach 7. can you please provide the code for this question in python , the part in bold gives a background .arrow_forwardAn ordinary ruler is a straight piece of wood where distances 0, 1, 2 . . . , N are marked, for some N ≥ 1. A sparse ruler (or simply a ruler ) is an ordinary ruler from which some of the numbers 1, . . . , N −1 may have been deleted. The number of marks on the ruler is its order and the value N is its reach. Here, we will represent a ruler as a Python list of strictly increasing integers starting with 0. For instance [0,1,3,7] is a ruler of order 4 and reach 7. A sparse ruler of reach N is complete if it is possible to measure all distances between 1 and N by taking the dierences between two marks. For instance [0,1,3] is complete because the pairs (0, 1), (1, 3), and (0, 3) yield distances of 1, 2, and 3 respectively. (Note that the pair of marks do not need to be consecutive.) On the other hand, [0,1,4] is not complete as there is no way to measure a distance of 2. could you please provide the code for this question in python , the parts in bold explain some of the concepts in this…arrow_forward
- The list Q has numbers 1, square root of 2, x, and x^2, where x>0 and the range of the numbers in the list is 4. quanity A= x quanity b= 2 which quanity is greater?arrow_forwardProblem Alice was given a number line containing every positive integer, x, where 1<=x<=n. She was also given m line segments, each having a left endpoint, l (1<=l<=n), a right endpoint, r (1<=r<=n), and an integer weight, w. Her task is to cover all numbers on the given number line using a subset of the line segments, such that the maximum weight among all the line segments in the chosen subset is minimal. In other words, let S=(l1,r1,w1),(l2,r2,w2),....,(lk,rk,wk), represent a set of k line segments chosen by Alice, max(w1,w2,...,wk) should be minimized. All numbers 1,2,....n should be covered by at least one of k the chosen line segments. It is okay for the chosen line segments to overlap. You program should output the minimized maximum weight in the chosen subset that covers all the numbers on the number line, or -1 if it is not possible to cover the number line. Input format The first line of the input contains an integer, n - denoting the range of numbers…arrow_forwardWrite a function triple_riffle_repeat(mylist,n) which takes as input a list (again with length a multiple of 3) and outputs the result of doing a 3-way riffle shufffle n times Write a function period(m) which takes as input a number m (which we will always take as a multiple of 3) and outputs the smallest positive integer n so that triple_riffle_repeat(list(range(m)),n) == list(range(m)) Discuss, with evidence, the outputs of your function period for different values of m, writing your answer as a comment.arrow_forward
- Given N (2 <= N <= 100000) points and some integer K (1 <= K <= 1000). Your task is to find the largest set which is correlative to K. You can assume that only one largest set exists. N and K will be in the first line of the input. N lines will follow, each one with a single integer, representing the location of one of the points. Print the size of the largest set of points which is correlative to K, in the first line of the input. Remaining lines will contain the points of the set, one per line, in increasing order.arrow_forwardWrite a program that replaces words in a sentence. The input begins with an integer indicating the number of word replacement pairs (original and replacement) that follow. The next line of input begins with an integer indicating the number of words in the sentence that follows. Any word on the original list is replaced. Ex: If the input is: 3 automobile car manufacturer maker children kids 15 The automobile manufacturer recommends car seats for children if the automobile doesn't already have one. then the output is: The car maker recommends car seats for kids if the car doesn't already have one. You can assume the original words are unique. For coding simplicity, follow each output word by a space, even the last one. Hint: For words to replace, use two vectors: One for the original words, and the other for the replacements. Your program must define and call the following function that returns index of word's first occurrence in wordList. If not found, then the function returns -1.int…arrow_forwardWrite a function double lagrange(double x_int[], double y_int[], int n, double x) which calculates the value of the n-th order Lagrange’s polynomial Pn(x) defined for the set of nodes {x(0), y(0)}, ..., {x(n), y(n)}, for a given value of xarrow_forward
- EXAMPLE:Suppose we have the following weighted intervals. start finish weight 11 14 4 10 13 5 9 11 5 11 14 3 8 9 2 To solve the problem, we start out by sorting the intervals by finish time. This gives us the following. start finish weight 8 9 2 9 11 5 10 13 5 11 14 4 11 14 3 Next we calculate the p-values. P(j) = k where interval k is the last interval prior to interval j in the list below which does not conflict with interval j, or P(j) = 0 if all intervals prior to interval j conflict with it. # start finish weight P 1 8 9 2 0 2 9 11 5 1 3 10 13 5 1 4 11 14 3 2 5 11 14 4 2 Finally, we use the formula OPT(j) = max{OPT(j-1), weight(j)+ OPT(P(j))} to fill in the OPT value for each j. (The base case where j=1 is that…arrow_forwarda. Write a version of the sequential search algorithm that can be used to search a sorted list. (1, 2) b. Consider the following list: 2, 20, 38, 41, 49, 56, 62, 70, 88, 95, 100, 135, 145 Using a sequential search on ordered lists, that you designed in (a), how many comparisons are required to determine whether the following items are in the list? (Recall that comparisons mean item comparisons, not index comparisons.) (1, 2) 2 57 88 70 135 Write a program to test the function you designed. Note: Have the function,seqOrdSearch, return -1 if the item is not found in the list. (return the index of the item if found).arrow_forwardcode in scala def unfold[A, S](z: S)(f: S => Option[(A, S)]): LazyList[A] = f(z) match { case Some((h, s)) => h #:: unfold(s)(f) case None => LazyList() } A positive integer is perfect if it equals the sum of all of its factors, excluding the number itself. For example, 6, 28, 496, and so on. Define a LazyList to generate an infinite list of perfect numbers. Use higher-order functions whenever possible. [Hint: One way to do this is by (1) having one function construct a list of factors (use unfold and filter for this), (2) having another function which folds the list of factors into their sum, and (3) creating a LazyList using unfold, filter and the previously constructed functions.] e number itself. For example, 6, 28, 496, and so on. Define a LazyList to generate an infinite list of perfectarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education