Starting Out with C++ from Control Structures to Objects (9th Edition)
9th Edition
ISBN: 9780134498379
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 7, Problem 37RQE
To store a value in a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Class and Data members:
Create a class called Student that stores a student’s grades (integers) in a vector (do not use an array). The class should have data members that store a student’s name and course for which the grades are earned.
Constructor(s):
The class should have a 2-argument constructor that receives the student’s name and course as parameters and sets the appropriate data members to these values.
Member Functions:
The class should have functions as follows:
Member functions to set and get the student’s name and course variables.
A member function that adds a single grade to the vector. Only positive grades are allowed. Call this function AddGrade.
A member function to sort the vector in ascending order.
A member function to compute the average (x̄) of the grades in the vector. The formula for calculating an average is
x̄ = ∑xi / n where xi is the value of each grade and n is the total number of grades in the vector.
A member function to determine the lowest…
struct remove_from_front_of_vector {
// Function takes no parameters, removes the book at the front of a vector,
// and returns nothing.
void operator()(const Book& unused) {
(/// TO-DO (12) |||||
// //
// Write the lines of code to remove the book at the front of "my_vector".
//
// Remember, attempting to remove an element from an empty data structure is
// a logic error. Include code to avoid that.
//// END-TO-DO (12) /||,
}
std::vector& my_vector;
};
1. Array Allocator
Write a function that dynamically allocates an array of integers. The function should accept an
integer argument indicating the number of elements to allocate. The function should return a
pointer to the array.
Chapter 7 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Ch. 7.3 - Define the following arrays: A) empNums, a...Ch. 7.3 - Prob. 7.2CPCh. 7.3 - Prob. 7.3CPCh. 7.3 - Prob. 7.4CPCh. 7.3 - What is array bounds checking? Does C++ perform...Ch. 7.3 - What is the output of the following code? int...Ch. 7.3 - The following program skeleton contains a...Ch. 7.3 - Define the following arrays: A) ages, a 10-element...Ch. 7.3 - Is each of the following a valid or invalid array...Ch. 7.6 - Given the following array definition: int values[]...
Ch. 7.6 - Given the following array definition: int nums[5]...Ch. 7.6 - Prob. 7.12CPCh. 7.6 - What is the output of the following code? (You may...Ch. 7.7 - Prob. 7.14CPCh. 7.7 - Prob. 7.15CPCh. 7.7 - When used as function arguments, are arrays passed...Ch. 7.7 - What is the output of the following program? (You...Ch. 7.7 - The following program skeleton, when completed,...Ch. 7.9 - Prob. 7.19CPCh. 7.9 - How many elements are in the following array?...Ch. 7.9 - Write a statement that assigns the value 56893.12...Ch. 7.9 - Prob. 7.22CPCh. 7.9 - Prob. 7.23CPCh. 7.9 - Fill in the table below so that it shows the...Ch. 7.9 - Write a function called displayArray7. The...Ch. 7.9 - A video rental store keeps DVDs on 50 racks with...Ch. 7.11 - Prob. 7.27CPCh. 7.11 - Write a definition statement for a vector named...Ch. 7.11 - Prob. 7.29CPCh. 7.11 - Write a definition statement for a vector named...Ch. 7.11 - Prob. 7.31CPCh. 7.11 - snakes is a vector of doubles, with 10 elements....Ch. 7 - Prob. 1RQECh. 7 - Look at the following array definition: int...Ch. 7 - Why should a function that accepts an array as an...Ch. 7 - Prob. 4RQECh. 7 - Prob. 5RQECh. 7 - Prob. 6RQECh. 7 - Prob. 7RQECh. 7 - Assuming that numbers is an array of doubles, will...Ch. 7 - Prob. 9RQECh. 7 - Prob. 10RQECh. 7 - How do you establish a parallel relationship...Ch. 7 - Prob. 12RQECh. 7 - When writing a function that accepts a...Ch. 7 - What advantages does a vector offer over an array?Ch. 7 - Prob. 15RQECh. 7 - The size declarator must be a(n) ________ with a...Ch. 7 - Prob. 17RQECh. 7 - Prob. 18RQECh. 7 - The number inside the brackets of an array...Ch. 7 - C++ has no array ________ checking, which means...Ch. 7 - Starting values for an array may be specified with...Ch. 7 - If an array is partially initialized, the...Ch. 7 - If the size declarator of an array definition is...Ch. 7 - By using the same _________ for multiple arrays,...Ch. 7 - Prob. 25RQECh. 7 - Prob. 26RQECh. 7 - To pass an array to a function, pass the ________...Ch. 7 - A(n) _______ array is like several arrays of the...Ch. 7 - Its best to think of a two-dimensional array as...Ch. 7 - Prob. 30RQECh. 7 - Prob. 31RQECh. 7 - When a two-dimensional array is passed to a...Ch. 7 - The ________________ is a collection of...Ch. 7 - The two types of containers defined by the STL are...Ch. 7 - The vector data type is a(n) ____________...Ch. 7 - Prob. 36RQECh. 7 - To store a value in a vector that docs nor have a...Ch. 7 - To determine the number of elements in a vector,...Ch. 7 - Use the _______________ member function to remove...Ch. 7 - To completely clear the contents of a vector, use...Ch. 7 - Prob. 41RQECh. 7 - Prob. 42RQECh. 7 - In a program, you need to store the identification...Ch. 7 - Prob. 44RQECh. 7 - In a program, you need to store the populations of...Ch. 7 - The following code totals the values in two...Ch. 7 - Prob. 47RQECh. 7 - Prob. 48RQECh. 7 - Prob. 49RQECh. 7 - Prob. 50RQECh. 7 - Prob. 51RQECh. 7 - T F The individual elements of an array are...Ch. 7 - T F The first element in an array is accessed by...Ch. 7 - Prob. 54RQECh. 7 - Prob. 55RQECh. 7 - T F Subscript numbers may be stored in variables.Ch. 7 - T F You can write programs that use invalid...Ch. 7 - Prob. 58RQECh. 7 - T F The values in an initialization list are...Ch. 7 - T F C++ allows you to partially initialize an...Ch. 7 - T F If an array is partially initialized, the...Ch. 7 - T F If you leave an element uninitialized, you do...Ch. 7 - T F If you leave out the size declarator of an...Ch. 7 - T F The uninitialized elements of a string array...Ch. 7 - T F You cannot use the assignment operator to copy...Ch. 7 - Prob. 66RQECh. 7 - T F To pass an array to a function, pass the name...Ch. 7 - T F When defining a parameter variable to hold a...Ch. 7 - T F When an array is passed to a function, the...Ch. 7 - T F A two-dimensional array is like several...Ch. 7 - T F Its best to think of two-dimensional arrays as...Ch. 7 - T F The first size declarator (in the declaration...Ch. 7 - T F Two-dimensional arrays may be passed to...Ch. 7 - T F C++ allows you to create arrays with three or...Ch. 7 - Prob. 75RQECh. 7 - T F To use a vector, you must include the vector...Ch. 7 - T F vectors can report the number of elements they...Ch. 7 - T F You can use the [ ] operator to insert a value...Ch. 7 - T F If you add a value to a vector that is already...Ch. 7 - int sixe; double values [size];Ch. 7 - Prob. 81RQECh. 7 - Prob. 82RQECh. 7 - Prob. 83RQECh. 7 - int numbers[8] ={1,2, , ,4, , 5};Ch. 7 - float ratings[] ;Ch. 7 - Prob. 86RQECh. 7 - Prob. 87RQECh. 7 - Prob. 88RQECh. 7 - void showValues(int nums [4][]) { For (rows = 0;...Ch. 7 - Prob. 90RQECh. 7 - Largest/Smallest Array Values Write a program that...Ch. 7 - Rainfall Statistics Write a program that lets the...Ch. 7 - Chips and Salsa Write a program that lets a maker...Ch. 7 - Larger than n In a program, write a function that...Ch. 7 - Monkey Business A local zoo wants to keep track of...Ch. 7 - Rain or Shine An amateur meteorologist wants to...Ch. 7 - Number Analysis Program Write a program that asks...Ch. 7 - Lo Shu Magic Square The Lo Shu Magic Square is a...Ch. 7 - Payroll Write a program that uses the following...Ch. 7 - Drivers License Exam The local Drivers License...Ch. 7 - Prob. 11PCCh. 7 - Grade Book A teacher has five students who have...Ch. 7 - Grade Book Modification Modify the grade book...Ch. 7 - Lottery Application Write a program that simulates...Ch. 7 - vector Modification Modify the National Commerce...Ch. 7 - World Series Champions If you have downloaded this...Ch. 7 - Name Search If you have downloaded this books...Ch. 7 - Tic-Tac-Toe Game Write a program that allows two...Ch. 7 - 2D Array Operations Write a program that creates a...Ch. 7 - Prob. 22PC
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Assume the following statement has been executed: number = 1234567.456 Write a Python statement that displays t...
Starting Out with Python (4th Edition)
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
In the array declaration double score(5); state the following: a. The array name b. The base type c. The declar...
Problem Solving with C++ (10th Edition)
In Exercises 3 through 24, carry out the task.
Create a button containing the word “PUSH” with the letter H as...
Introduction To Programming Using Visual Basic (11th Edition)
What are some features of specific programming languages you know whose rationales are a mystery to you?
Concepts Of Programming Languages
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
- CorrectFormation Create a program and locally declare in main fname and Iname and completeName. Ask the user for their first and last name. Put the values into fname and Iname. You will create a function that is called as followed. joinNames( fname, Iname, completeName ); You will pass the first name array, the last name array, and the array that will contain the complete name. The function named joinNames should put the first and last names together in completeName. Make sure that the first and last names begin with capital letters, and that ll others are lower case. Display the final combined name. O X Please enter your first name:chuck wagon Please enter your last name:The complete name is Chuck Wagon Process returned e (@x) execution time : 5.192 5 Press any key to continue.arrow_forwardc++ programming languagearrow_forward10. When using a std::vector, what values do we expect to get from the size and empty member functions after calling the clear member function? Complete the table below with the expected values. member function value after donations.clear() donations.size() donations.empty()arrow_forward
- Class and Data members: Create a class called Temperature that stores temperature readings (integers) in a vector (do not use an array). The class should have data members that store the month name and year of when the temperature readings were collected. Constructor(s): The class should have a 2-argument constructor that receives the month name and year as parameters and sets the appropriate data members to these values. Member Functions: The class should have functions as follows: Member functions to set and get the month and year variables. A member function that adds a single temperature to the vector. Both negative and positive temperatures are allowed. Call this function AddTemperature. A member function to sort the vector in ascending order. Feel free to use the sort function that is available in the algorithm library for sorting vectors. Or, if you would prefer to write your own sort code, you may find this site to be helpful:…arrow_forwardPlease write the code for the removeBad function. Will thumbs up if correct!arrow_forwardTo define a vector in your program, you must #include the ____________ headerfile.arrow_forward
- use c++ Programming language Write a program that creates a two dimensional array initialized with test data. Use any data type you wish . The program should have following functions: .getAverage: This function should accept a two dimensional array as its argument and return the average of each row (each student have their average) and each column (class test average) all the values in the array. .getRowTotal: This function should accept a two dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a row in the array. The function should return the total of the values in the specified row. .getColumnTotal: This function should accept a two dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a column in the array. The function should return the total of the values in the specified column. .getHighestInRow: This function should accept a two…arrow_forwardIn C, in order to do operations to the data being referenced by a pointer you would need to use the (*) operator, which is called ______________ operator.arrow_forwardPHP Write a reduce function Write a function reduce($arr, $func) that takes an array and a function as a parameter. The reduce function should apply the parameter function to each element of the array in succession to produce a single result. Note: the current result should always be the first parameter to the function and the next element of the array should always be the second parameter. You may not use the PHP function array_reduce in your solution. For example, the result of the following should be 10. function myMax($current, $new) { return $current < $new ? $new : $current; } $arr = array(10, 5, 3, 5, 1, 2, 5, 7, 4); print("Max: " . reduce($arr, 'myMax') .arrow_forward
- Create an Organization class. Organization has 10 Employees (Hint: You will need an array of pointers to Employee class) Organization can calculate the total amount to be paid to all employees Organization can print the details(name & salary) of all employees note: write code in main,header and function.cpp filearrow_forwardA1: File Handling with struct C++ This program is to read a given file and display the information about employees according to the type of employee. Specifically, the requirements are as follows. Read the given file of the information of employees. Store the information in an array or arrays. Display all the salaried employees first and then the hourly employees Prompt the user to enter an SSN and find the corresponding employee and display the information of that employee. NOTE : S- salaryemployee , H- Hourly employee S 135-25-1234 Smith Sophia DevOps Developer 70000H 135-67-5462 Johnaon Jacob SecOps Pentester 30 60.50S 252-34-6728 William Emma DevOps DBExpert 100000S 237-12-1289 Miller Mason DevOps CloudArchitect 80000S 581-23-4536 Jones Jayden SecOps Pentester 250000S 501-56-9724 Rogers Mia DevOps Auditor 90000H 408-67-8234 Cook Chloe DevOps QAEngineer 40 45.10S 516-34-6524 Morris Daniel DevOps ProductOwner 300000H 526-47-2435 Smith Natalie DevOps…arrow_forwardPlease code in C++ IDE USE COMMENTS AND EXPLAIN CODE PLEASEarrow_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 LearningProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
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