MyProgrammingLab - For Gaddis: Starting Out with C++ From Control Structures through Objects
MyProgrammingLab - For Gaddis: Starting Out with C++ From Control Structures through Objects
15th Edition
ISBN: 9780133780611
Author: Pearson
Publisher: PEARSON
bartleby

Videos

Question
Book Icon
Chapter 16, Problem 13PC
Program Plan Intro

Rainfall vector

Program Plan:

  • Include the required header files into the program.
  • Include the “vector” header file to implement vector operations.
  • Declare and define a constant variable named “n” in type of integer.
  • Declare function prototypes.
  • Define the function “main ()”.
    • Declare a vector object named “rainfall ()” in type of “double”.
    • Using “for” loop to get rainfall inches from user and validate the input using loop.
    • Call the function named “getTotal ()” to calculate the total value of rainfall inches.
    • Call the function named “getAverage ()” to calculate the average value of rainfall inches.
    • Call the function named “getLargest ()” to find largest value of rainfall inches with “subScript” value.
    • Call the function named “getSmallest ()” to find smallest value of rainfall inches “subScript” value.
  • Define a function named “getTotal ()” which contains a parameter named “vec” of type “double”.
    • Declare a variable “total” and assign the value “0” to it.
    • Use “for” loop to add the vector values and store it in a variable “total”.
    • Return the value of “total”.
  • Define a function named “getAverage ()”which contains a parameter named “vec” of type “double”.
    • Calculate the average value from total and store the value in a variable “average”.
    • Return the value of “average”.
  • Define a function named “getLargest ()” to find the largest value from vector.
    • Declare a variable “largest” of type “double”.
    • Assign the first value of vector into “largest” variable.
    • Assign the value “0” into variable “element”.
    • Using “for” loop to find largest value from vector.
      • Using “if” condition, check whether the vector value is greater than value of “largest”.
        • If the condition is true then assign the value of vector into “largest” variable.
        • Assign the value of “count” into  a variable “element”
    • Return the value of “largest” to called function.
  • Define a function named “getSmallest ()” to find the smallest value from vector.
    • Declare a variable “smallest” in type of “double”.
    • Assign the first value of vector to the variable “smallest”.
    • Assign the value “0” to a variable “element”.
    • Use “for” loop to find the smallest value from vector.
      • Using “if” condition, check whether the vector value is smaller than value of “smallest”.
        • If the condition is true then assign the value of vector to the variable “smallest”.
        • Assign the value of “count” into  a variable “element”
    • Return the value of “smallest”.

Blurred answer

Chapter 16 Solutions

MyProgrammingLab - For Gaddis: Starting Out with C++ From Control Structures through Objects

Ch. 16.4 - Prob. 16.11CPCh. 16 - Prob. 1RQECh. 16 - Prob. 2RQECh. 16 - Prob. 3RQECh. 16 - Prob. 4RQECh. 16 - What is unwinding the stack?Ch. 16 - What happens if an exception is thrown by a classs...Ch. 16 - How do you prevent a program from halting when the...Ch. 16 - Why is it more convenient to write a function...Ch. 16 - Why must you be careful when writing a function...Ch. 16 - Prob. 10RQECh. 16 - Prob. 11RQECh. 16 - Prob. 12RQECh. 16 - The line containing a throw statement is known as...Ch. 16 - Prob. 14RQECh. 16 - Prob. 15RQECh. 16 - Prob. 16RQECh. 16 - The beginning of a template is marked by a(n)...Ch. 16 - Prob. 18RQECh. 16 - Prob. 19RQECh. 16 - Prob. 20RQECh. 16 - Prob. 21RQECh. 16 - _____________ are pointer-like objects used to...Ch. 16 - Prob. 23RQECh. 16 - Write a function that searches a numeric array for...Ch. 16 - Write a function that dynamically allocates a...Ch. 16 - Make the function you wrote in Question 17 a...Ch. 16 - Write a template for a function that displays the...Ch. 16 - Prob. 28RQECh. 16 - Prob. 29RQECh. 16 - Prob. 30RQECh. 16 - Prob. 31RQECh. 16 - Prob. 32RQECh. 16 - Prob. 33RQECh. 16 - Prob. 34RQECh. 16 - T F All type parameters defined in a function...Ch. 16 - Prob. 36RQECh. 16 - T F A class object passed to a function template...Ch. 16 - Prob. 38RQECh. 16 - Prob. 39RQECh. 16 - Prob. 40RQECh. 16 - Prob. 41RQECh. 16 - T F A class template may not be derived from...Ch. 16 - T F A class template may not be used as a base...Ch. 16 - Prob. 44RQECh. 16 - Prob. 45RQECh. 16 - Prob. 46RQECh. 16 - Prob. 47RQECh. 16 - try { quotient = divide(num1, num2); } cout The...Ch. 16 - template class T T square(T number) { return T T;...Ch. 16 - template class T int square(int number) { return...Ch. 16 - Prob. 51RQECh. 16 - Assume the following definition appears in a...Ch. 16 - Assume the following statement appears in a...Ch. 16 - Prob. 1PCCh. 16 - Prob. 2PCCh. 16 - Prob. 3PCCh. 16 - Prob. 4PCCh. 16 - Prob. 5PCCh. 16 - IntArray Class Exception Chapter 14 presented an...Ch. 16 - TestScores Class Write a class named TestScores....Ch. 16 - Prob. 9PCCh. 16 - SortableVector Class Template Write a class...Ch. 16 - Inheritance Modification Assuming you have...Ch. 16 - Prob. 12PCCh. 16 - Prob. 13PCCh. 16 - 14. Test Scores vector Modify Programming...Ch. 16 - Prob. 15PCCh. 16 - Prob. 16PCCh. 16 - Prob. 17PC
Knowledge Booster
Background pattern image
Computer Science
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.
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
1.1 Arrays in Data Structure | Declaration, Initialization, Memory representation; Author: Jenny's lectures CS/IT NET&JRF;https://www.youtube.com/watch?v=AT14lCXuMKI;License: Standard YouTube License, CC-BY
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License