Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 11.3, Problem 19STE
Give a type definition for a structure called Score that has two member variables called homeTeam and opponent. Both member variables are of type int. Declare an array called game that is an array with ten elements of type Score. The array game might be used to record the scores of each of ten games for a sports team.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
In C++, create a class for a 3-dimensional array. To make it more general, allow the actual dimensionality to be 0d, 1d, 2d, or 3d. It should support indexing with operator(). If the programmer subscripts with fewer indices than you 'need' (0 for a 1d, 0 or 1 for a 2d, 0 or 1 or 2 for a 3d -- note that you can't under-subscript a 0d array), you should return the appropriately sized sub-array (of your class's type). (Note: This will require multiple overloads of operator() with different numbers of index arguments.)
Since, as a template, math operations don't make sense, you'll have to for-go addition, etc. But you could use + and += for concatenation. Basically aligning the common dimensions of the two arrays and concatenating along the remaining dimension. (There can be only one for this to make sense. If there are none remaining, there are options for those kinds of things!) Make sure to overload it for proper dimensionality:
Of course, you should also support input (the programmer…
Write the answers in c++
1. Define a struct for a soccer player that stores their name, jersey number, and total points scored.
2.Using the struct in #1, write a function that takes an array of soccer players and its size as arguments and returns the average number of points scored by the players.
3.Using the struct in #1, write a function that takes an array of soccer players and its size as arguments and returns the index of the player who scored the most points.
4.Using the struct in #1, write a function that sorts an array of soccer players by name.
5.Using the struct in #1, write a function that takes an (unsorted) array of soccer players and its size and a number as arguments, and returns the name of the soccer player with that number. It should not do any extra unnecessary work.
6.Define a function to find a given target value in an array, but use pointer notation rather than array notation whenever possible.
7.Write a swap function, that swaps the values of two variables in…
Under which of the following conditions, the size of an one-dimensional array need not be specified?
A.
when initialization is a part of definition
B.
when it is a declaration
C.
when it is a formal parameter and an actual argument
D.
All of the above
Chapter 11 Solutions
Problem Solving with C++ (10th Edition)
Ch. 11.1 - Write a function definition for a function called...Ch. 11.1 - What is the difference between a friend function...Ch. 11.1 - Suppose you wish to add a friend function to the...Ch. 11.1 - Prob. 4STECh. 11.1 - Notice the member function output in the class...Ch. 11.1 - Notice the definition of the member function input...Ch. 11.1 - The Pitfall section entitled Leading Zeros in...Ch. 11.1 - Give the complete definition of the member...Ch. 11.1 - Why would it be incorrect to add the modifier...Ch. 11.1 - What are the differences and the similarities...
Ch. 11.1 - Given the following definitions: const int x = 17;...Ch. 11.2 - What is the difference between a (binary) operator...Ch. 11.2 - Prob. 13STECh. 11.2 - Suppose you wish to overload the operator = so...Ch. 11.2 - Prob. 15STECh. 11.2 - Give the definition for the constructor discussed...Ch. 11.2 - Here is a definition of a class called Pairs....Ch. 11.2 - Following is the definition for a class called...Ch. 11.3 - Give a type definition for a structure called...Ch. 11.3 - Write a program that reads in five amounts of...Ch. 11.3 - Change the class TemperatureList given in Display...Ch. 11.3 - Prob. 22STECh. 11.3 - If a class is named MyClass and it has a...Ch. 11.4 - Prob. 24STECh. 11.4 - The following is the first line of the copy...Ch. 11.4 - Answer these questions about destructors. a. What...Ch. 11.4 - a. Explain carefully why no overloaded assignment...Ch. 11 - Modify the definition of the class Money shown in...Ch. 11 - Self-Test Exercise 17 asked you to overload the...Ch. 11 - Self-Test Exercise 18 asked you to overload the...Ch. 11 - Prob. 1PPCh. 11 - Define a class for rational numbers. A rational...Ch. 11 - Define a class for complex numbers. A complex...Ch. 11 - Enhance the definition of the class StringVar...Ch. 11 - Define a class called List that can hold a list of...Ch. 11 - Define a class called StringSet that will be used...Ch. 11 - This programming project requires you to complete...Ch. 11 - Redo Programming Project 6 from Chapter 9 (or do...Ch. 11 - Solution to Programming Project 11.12 To combat...Ch. 11 - Repeat Programming Project 11 from Chapter 10 but...Ch. 11 - Do Programming Project 19 from Chapter 8 except...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Bond Yield One measure of a bond's performance is its Yield To Maturity (YTM). YTM values for government bonds ...
Introduction To Programming Using Visual Basic (11th Edition)
Words that have predefined meaning in a programming language are called _____ .
Starting Out With Visual Basic (8th Edition)
Demonstrate each of the anomaly types with an example.
Modern Database Management (12th Edition)
Write a method definition for a method called isGrowthRateLargeThan that could be added to the class Species in...
Java: An Introduction to Problem Solving and Programming (7th Edition)
The is-a relation between classes is best implemented using the mechanism of class _____.
Starting Out with C++: Early Objects (9th Edition)
What are the advantages and disadvantages of implicit declarations?
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
- I wish to write a program to keep track of my coat hanger collection, I need a data structure for recording the following information for each hanger: the hanger type (string), the date of acquisition (int), and the value (double). I own less than 500 coat hangers. Write the declarations for an array of struct to contain the information. Please write only the declarations; do not write any functions. C++arrow_forwardC++ Write a program that declares a struct to store the data of a football player (player’s name, player’s position, number of touchdowns, number of catches, number of passing yards, number of receiving yards, and the number of rushing yards). Declare an array of 10 components to store the data of 10 football players. Your program must contain a function to input data and a function to output data. Add functions to search the array to find the index of a specific player, and up-date the data of a player. (You may assume that the input data is stored in a file.) Before the program terminates, give the user the option to save data in a file. Your program should be menu driven, giving the user various choices. An example of the program is shown below: Select one of the following options: 1: To print a player's data 2: To print the entire data 3: To update a player's touch downs 4: To update a player's number of catches 5: To update a player's passing yards 6: To update a player's…arrow_forwardfor c++ Write a program that allows two players to play the tick-tac-toe game. Your program must contain the class ticTacToe to implement a ticTacToe object. Include a 3-by-3 two-dimensional array, as a private member variable, to create the board. If needed, include additional member variables. Some of the operations on a ticTacToe object are printing the current board, getting a move, checking if a move is valid, and determining the winner after each move. Add additional operations as needed.arrow_forward
- In the Programming (Part 1) you will create an array of Leg objects. There's just one constructor, and it takes three parameters -- two city names (like "San Francisco" and "Pleasant Hill") as constant C string, and one number representing the distance in miles between the two cities (whole number or floating point -- your choice). Write a code block to create a static array (that is, not dynamic and not a vector) of 3 Leg objects using city names of your choosing. That's THREE objects, each created using THREE parameters. For example, the Leg class declaration looked like, class Leg { const char* const startCity; const char* const endCity; const double distance; public: Leg(const char* const, const char* const, const double); }; HINT: "constant C strings" as parameters and as constant data members are const char* const constant read-only pointers. Do NOT use char arrays for this (that is, no square brackets). When you write code for an exercise like this, write in…arrow_forwardWrite in C++ 1. Define a struct for a soccer player that stores their name, jersey number, and total points scored. 2.Using the struct in #1, write a function that takes an array of soccer players and its size as arguments and returns the average number of points scored by the players. 3.Using the struct in #1, write a function that takes an array of soccer players and its size as arguments and returns the index of the player who scored the most points. 4.Using the struct in #1, write a function that sorts an array of soccer players by name. 5.Using the struct in #1, write a function that takes an (unsorted) array of soccer players and its size and a number as arguments, and returns the name of the soccer player with that number. It should not do any extra unnecessary work. 6.Define a function to find a given target value in an array, but use pointer notation rather than array notation whenever possible. 7.Write a swap function, that swaps the values of two variables in main, but use…arrow_forwardConsider the following array declaration:double a[10] = { 1.1 , 2.2, 3.3, 4.4, 5.5 };Write a function named circularShiftLeft that will move each element of this array(or any array of doubles) one space to the left, with the rst element being moved tothe last spot. For example, after calling circularShiftLeft, the above array wouldcontain {2.2, 3.3, 4.4, 5.5, 1.1}.The function should work for an arbitrary array of doubles. Be sure to avoidavoid illegal array indices. In C programmingarrow_forward
- C++ Write a function named “getTotalHourAndPayout” that accepts an array ofPayStub object pointers and its size. It will return the total number of hours andpayout amount for all of the PayStub in the given array. For example, if we have two paystubs of 40 hours and $10 pay rate with 50 hoursand $10 pay rate, it will return 90 hours and $950.Please show you would call and test this function.arrow_forward3. Write a function named “getCombinedPurchaseOrder” that accepts an array of PurchaseOrder object pointers, its size, description, and cost per item. It will go through the list in the array and return a pointer of a new PurchaseOrderobject that contains the total quantity of all the matched PurchaseOrderobjects(with the same description symbol and cost per item). It will return NULL if there is no match. For example, these 2 PurchaseOrderobjects with (100, 1.25, "A box of candy") and (200, 1.25, "A box of candy")will be combined into one new PurchaseOrderobjecthaving the quantity of 300. Please note that this function returns 2 separate values: the pointer to the newly created object and the number of matched PurchaseOrderobjects found in the list. 4. Write a function named “removeNegativePrice” that accepts the vector of pointers to PurchaseOrderobjects. It will go through that list and remove all PurchaseOrderobjectswiththenegativecost per item. It will also return how many…arrow_forwardWrite a program that has a struct studentType that contains the following members of type string, first, last, and type int grade, section, and type double gpa. The program should define the struct and declare an array studentType, size 3. Prompt the user for the information for the struct and the data should be read in and set for each student. Once all of the data has been read in, write it back out using the formatting show below. Example of this: g++ -Wall-pedantic -Wextra main.cpp ./a.out Enter first last grade section gpa:a mouse 3 1003 2.95 Enter first last grade section gpa:b mouse 4 1005 3.01 Enter first last grade section gpa:c mouse 2 1000 4.0 Student 0 a mouse 3 1003 2.95 Student 1 b mouse 4 1005 3.01 Student 2 c mouse 2 1000 4arrow_forward
- The bank will store a record for each account consisting of a customer number (an integer) representing the owner of the account, an account type (a single char: C for chequing, S for savings, and M for mutual fund), and the balance of the account (a double). These are kept in three arrays-an array of customer numbers, an array of types, and an array of balances. A sample of what this might look like appears below: Customer Array 102241 992944 992944 Type Array C S C Balance Array 1.29 22.50 1.24 The entries in the array correspond to one another-for example, the first slot in all three arrays represent the fact that customer number 102241 has a chequing account with $1.29 in it. As is shown, the same customer number can appear several times, as customers can have more than one account. These are called parallel arrays, because the slots in each correspond, and the really important thing about parallel arrays is that if you shuffle around anything in one array, you have to…arrow_forwardThe bank will store a record for each account consisting of a customer number (an integer) representing the owner of the account, an account type (a single char: C for chequing, S for savings, and M for mutual fund), and the balance of the account (a double). These are kept in three arrays-an array of customer numbers, an array of types, and an array of balances. A sample of what this might look like appears below: Customer Array 102241 992944 992944 Type Array C S C Balance Array 1.29 22.50 1.24 The entries in the array correspond to one another-for example, the first slot in all three arrays represent the fact that customer number 102241 has a chequing account with $1.29 in it. As is shown, the same customer number can appear several times, as customers can have more than one account. These are called parallel arrays, because the slots in each correspond, and the really important thing about parallel arrays is that if you shuffle around anything in one array, you have to…arrow_forwardIn C++, Define a “Invalidanalyze” function that accepts an array of “Course” objects. It will return the following information to the caller: - The number of courses with empty or blank description - The number of courses with invalid negative units - The number of courses with invalid day number of the week - The total number of units for all invalid courses in the array Show how this method is being called and return proper information.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 Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Call By Value & Call By Reference in C; Author: Neso Academy;https://www.youtube.com/watch?v=HEiPxjVR8CU;License: Standard YouTube License, CC-BY