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 15PC
vector Modification
Modify the National Commerce Bank case study presented in
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
C++ Vectors Help:
write a program using parallel vectors and a function which fills each of them with 500 random numbers between 1 and 100. The program should then pass both vectors to a function which will return an integer indicating a count of how many times both vectors had even numbers in the same location. So if vector01[0] contained 4 and vector02[0] contained 12, you would add one to count.If vector01[1] contained 3 and vector02[1] contained 4, you would not add one to count.
main would display something like :
The Vectors contain 128 cells where both values are even.
Above was the question: I already have the code written:
#include<iostream>
#include<vector>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int even = 0;
srand(time(0));
vector <int> vector01;
vector <int> vector02;
for (int i = 0; i < 500; i++)
{
vector01.push_back(rand() % 100 + 1);
vector02.push_back(rand() % 100 + 1);
if (vector01[i] % 2 == 0…
Use C++ programing language
Write a modular program that analyzes a year’s worth of rainfall data. In addition to main, the program should have a getData function that accepts the total rainfall for each of 12 months from the user and stores it in an array holding double numbers. It should also have four value-returning functions that compute and return to main the totalRainfall, averageRainfall, driestMonth, and wettestMonth. These last two functions return the number of the month with the lowest and highest rainfall amounts, not the amount of rain that fell those months. Notice that this month number can be used to obtain the amount of rain that fell those months. This information should be used either by main or by a displayReport function called by main to print a summary rainfall report similar to the following:
2019 Rain Report for Springdale County
Total rainfall: 23.19 inches
Average monthly rainfall: 1.93 inches
C++ Format Please
Write a function called SortByUpper, that takes a vector of strings and changes that vector to be sorted according to only the uppercase letters in each string. No other characters should be involved in determining the order of the vector.
For instance "zCAxT" < "aDyOG", because "CAT" < "DOG".
No loops just STL alogorithms and iterators
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
We have defined four binary logical connectives. a. Are there any others that might be useful? b. How many bina...
Artificial Intelligence: A Modern Approach
A condition-controlled loop always repeats a specific number of times.
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
(Modified Compound-Interest Program) Modify the compound-interest application of Fig. 5.6 to repeat its steps f...
Java How To Program (Early Objects)
If the period of a pulse waveform increases, the frequency also increases.
Digital Fundamentals (11th Edition)
Why do some standard SQL-92 statements fail to run successfully in Microsoft Access?
Database Concepts (7th Edition)
This project requires that you complete Programming Project 7 from this chapter and Programming Project 8 from ...
Problem Solving with C++ (9th Edition)
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
- C code blocks Implement a function which receives a character array and determines if the word is a palindrome or not. A palindrome is a string that is spelt the same way forwards and backwards (see the example below). The function should return 1 if the character array is a palindrome and 0 if it is not. Write the entire function in the space below. Your answer should not include the function prototype, the main function or any include statements. The function should not contain any printf statements. Define your function in the same way as the given function prototype. Function prototype: int palindrome(char a[]); For example: Input Result hello 0 radar 1 acca 1arrow_forwardC codeblocks Only write a function that receives an array, its size and a value to search for (define your function in the same way as the given function prototype). The function should return the index of the searched element in the array. If the element is not found, it should return -1. If the array has more than one element of that same value, it should return the value -2. The array is not necessarily sorted and should not be sorted in the function. #include <stdio.h>#include <stdlib.h>int searchIt(int arr[], int size, int value);int main() {int a[]={1,2,3,4,5};printf("%d", searchIt(a,5,3));return 0;}//Your answer starts here. For example: Test Result int a[]={1,2,3,4,5}; printf("%d", searchIt(a,5,3)); 2 int b[]={3,2,5,7,10,2,4}; printf("%d", searchIt(b,7,2)); -2 int c[]={-1,0,234,43,2,1,4,5}; printf("%d", searchIt(c,8,99)); -1arrow_forwardC++ Format Please Write a function (named "Lookup") that takes two const references to vectors. The first vector is a vector of strings. This vector is a list of words. The second parameter is a list of ints. Where each int denotes an index in the first vector. The function should return a string formed by concatenated the words (separated by a space) of the first vector in the order denoted by the second vector. Input of Test Case provided in PDF:arrow_forward
- c++ programming Write a function named maxCols which stores the maximum value in each row of a 3x3 2D array into a 1D array. This function should accept a 3x3 2D array, a 1D array and the size of each dimension as parameters. Example Calling maxCols with this 2D array:3 7 2 9 3 6 8 5 6 Results in the 1D array storing the values 7,9,8.arrow_forwardInstructions Write a program in C++ that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. The program should output the average high, average low, and the highest and lowest temperatures for the year. Your program must consist of the following functions: Function getData: This function reads and stores data in the two-dimensional array. Function averageHigh: This function calculates and returns the average high temperature for the year. Function averageLow: This function calculates and returns the average low temperature for the year. Function indexHighTemp: This function returns the index of the highest high temperature in the array. Function indexLowTemp: This function returns the index of the lowest low temperature in the array. These functions must all have the appropriate parameters. An example of the program is shown below: Enter high temperature for each month 60 68 72 72 73 76 80 81 75 72 67 66 Enter low temperature for…arrow_forwardCOMPUTER PROGRAMMING Data Validation Assignmentarrow_forward
- c++ questionarrow_forwardC++ I need to create a function that manipulates a vector. Create a function insert_back(n, x, v) that adds n copies of integerx to the back of vector v. The argument v is a vector of integers.arrow_forwardC++ PROGRAMMING Create a C++ program that accepts integer inputs into an array. Arrange the arrays into an ascending manner and display the missing elements in the arithmetic sequence. The number of repeating elements must be counted as well. There must be at least two user-defined functions in your program. Example 1: Input: 3, 4, 5, 1, 3, 7 Output Missing Numbers: 2, 6 Repeating: 1 Example 2: Input: 6, 1, 2, 20, 1, 2 Output Missing Numbers: 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19arrow_forward
- c++ program Q2 Write a C++ program to store values in a two-dimensional array i.e., 3x4 and then write a function that displays the elements of the array. You should take input in the main function and then pass the array to a “PrintArray” function. The function will print the array on the display.arrow_forwardIn C++ Create a function that takes in a vector, triples the size of the vector, sets all the values to random numbers, and returns the vector.arrow_forwardC++ Coding: ArraysTrue and False Code function definitions for eoNum() and output(): Both eoNum() and output() are recursive functions. output() stores the even/odd value in an array. Store 0 if the element in the data array is even and store 1 if the element in the data array is odd. eoNum() displays all the values in an array to the console.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 LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
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