Starting out With C++, Early Objects - Access
8th Edition
ISBN: 9780133452259
Author: GADDIS
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 19, Problem 9PC
Program Plan Intro
Cousins
Program Plan:
- Include all the required header files.
- Add enum for a range of values of Gender.
- Define class person.
- Define all the required variables along with their data types.
- Assign the name and gender of a person using functions string getName()and Gender getGender().
- Function to add child of a person Person *addChild is created.
- Function to add parents of a person void addParent is created.
- Function to get number of children of a person and return the number of children is created.
- Function to create a child with specified name and gender, and set one of the parents to this child Person *Person::addChild is called.
- Function to add siblings and step siblings of a given person to a
vector void addSiblings is created. - Function to add cousins of the person void addCousins is called.
- Define the main function.
- Add children of Adam and Amelia.
- Add Children of Amelia and Alan.
- Add Children of Alan and Anna.
- Add cousins from third generations.
- Find the cousins of at least two people, here consider Peter and Paul and find their cousins and display them.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a struct ‘Student’ that has member variables: (string) first name, (int) age and (double) fee. Create a sorted (in ascending order according to the age) linked list of three instances of the struct Student. The age of the students must be 21, 24 and 27. Write a function to insert the new instances (elements of the linked list), and insert three instance whose member variable have age (i) 20, (ii) 23 and (iii) 29. Write a function to remove the instances from the linked list, and remove the instances whose member variables have age (i) 21 and (ii) 29. Write a function to count the elements of the linked list. Write a function to search the elements from the linked list, and implement the function to search an element whose age is 23. Write a function to print the linked list on the console.
Consider the Student struct as defined above. Create a stack of 5objects of the class. Implement the following (i) push an element to the stack (ii) pop an element from the stack (iii) get the…
In C++
Define a structure called Date with month, day and year as its only integer members. Define a structure called Person with name (string) and birthDate (Date) as its only members. Define a ValidDate() function to retrun true if a Date passed to it is a valid date and false if not. Define a LeapYear() function that returns true if a year passed to it is a leap year and false if not. Define a ShowList() function that takes an array of Persons and its size and displays all its members' names and birthdates. Define a sort() function that takes an array of Persons and size and sorts the array based on their names in ascending order. Write a main() program where you declare an array of Person structures of maximum size 50, read as many Persons from the user as the user wants to enter and then display the list. Then, sort the list and display again. The user will hit the Enter key without typing anything else for the name when done.
For example, if the input is the following: Robert…
Write C code that implements a soccer team as a linked list.
1. Each node in the linkedlist should be a member of the team and should contain the following information:
What position they play
whether they are the captain or not
Their pay
2. Write a function that adds a new members to this linkedlist at the end of the list.
Chapter 19 Solutions
Starting out With C++, Early Objects - Access
Ch. 19.1 - Prob. 19.1CPCh. 19.1 - Prob. 19.2CPCh. 19.1 - Prob. 19.3CPCh. 19.1 - Prob. 19.4CPCh. 19.1 - Prob. 19.5CPCh. 19.1 - Prob. 19.6CPCh. 19.2 - Prob. 19.7CPCh. 19.2 - Prob. 19.8CPCh. 19.2 - Prob. 19.9CPCh. 19.2 - Prob. 19.10CP
Ch. 19.2 - Prob. 19.11CPCh. 19.2 - Prob. 19.12CPCh. 19 - Prob. 1RQECh. 19 - Prob. 2RQECh. 19 - Prob. 3RQECh. 19 - Prob. 4RQECh. 19 - Prob. 5RQECh. 19 - Prob. 6RQECh. 19 - Prob. 7RQECh. 19 - Prob. 8RQECh. 19 - Prob. 9RQECh. 19 - Prob. 10RQECh. 19 - Prob. 11RQECh. 19 - Prob. 12RQECh. 19 - Prob. 13RQECh. 19 - Prob. 14RQECh. 19 - Prob. 15RQECh. 19 - Prob. 16RQECh. 19 - Prob. 17RQECh. 19 - Prob. 18RQECh. 19 - Prob. 19RQECh. 19 - Prob. 20RQECh. 19 - Prob. 1PCCh. 19 - Prob. 2PCCh. 19 - Prob. 3PCCh. 19 - Prob. 4PCCh. 19 - Prob. 5PCCh. 19 - Prob. 6PCCh. 19 - Prob. 7PCCh. 19 - Prob. 8PCCh. 19 - Prob. 9PCCh. 19 - Prob. 10PC
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
- Write a struct ‘Student’ that has member variables: (string) first name, (int) age and (double) fee. Create a sorted (in ascending order according to the age) linked list of three instances of the struct Student. The age of the students must be 21, 24 and 27. Write a c++ function to insert the new instances (elements of the linked list), and insert three instance whose member variable have age (i) 20, (ii) 23 and (iii) 29. Write a c++ function to remove the instances from the linked list, and remove the instances whose member variables have age (i) 21 and (ii) 29. Write a c++ function to count the elements of the linked list. Write a c++ function to search the elements from the linked list, and implement the function to search an element whose age is 23. Write a c++ function to print the linked list on the console.arrow_forwardWrite a function nth_member(data, n) that takes a list data and an integer n as parameters and returns the nth member of the list of data, assuming the first member has an index of n = 0. You may assume that data contains at least n + 1 members.arrow_forwardIn C++, write a Employee class with id, name and salary; declare 3 dynamic objects (pointer and new keywords) and push them to the vector and print the vector.arrow_forward
- C++ Programming D.S.Malik12-10: Add the function max as an abstract function to the class arrayListType to return the largest element of the list. Also, write the definition of the function max in the class unorderedArrayListType and write a program to test this function.arrow_forwardWrite a function called findavg that takes a pointer to a struct student as inputand will return the average of the test scores in their list. Use the const keyword ifapplicable. Any help would be appreciated!arrow_forwardA dequeue is a list from which elements can be inserted or deleted at either end a. Develop an array based implementation for dequeue. b. Develop a pointer based implementation dequeue.arrow_forward
- HELP Write C code that implements a soccer team as a linked list. 1. Each node in the linkedlist should be a member of the team and should contain the following information: What position they play whether they are the captain or not Their pay 2. Write a function that adds a new members to this linkedlist at the end of the list.arrow_forwardC++ Write a class template that uses a vector to implement a stack data structure with these member functions: 1. (constructor) : Construct stack (public member function ) 2. empty : Test whether container is empty (public member function ) 3. size : Return size (public member function ) 4. top : Access next element (public member function ) 5. push : Insert element (public member function ) 6. pop : Remove top element (public member function ) Put function definitions outside the definition of the class (i.e. inline functions are not allowed).arrow_forwardWrite a struct Student that has member variables: (string) first name, (int) age and (double) fee. Write the functions as described in the class for the following purposes.1. Write a c++ function to create a dynamic sorted (in ascending order according to the age)doubly linked list, where the data component of each node is an instance of the structStudent.2. Write a function to insert the instances in the linked list. You also need to write a function to find the spot for insertion of the nodes.3. Write a function to remove the node from the linked list.4. Write a function to count the elements of the linked list.5. Write a function to determine check whether an element belongs to the linked list.6. Write a function to print the linked list (from head node) on the console.7. Write a function to print the linked list (from tail node) on the console. Implement the above functions as follows.Initially, the list must have five nodes that are the instances of the struct whose member…arrow_forward
- Design a function that consumes a natural number and produces a list ofstrings describing that many seats at a table. For example, (seats 3) shouldproduce the list (list "Seat 1" "Seat 2" "Seat 3"). Include all recipe elements. The body of your function definition MUSTUSE the build-list built-in abstract function. You may optionally use anadditional built-in abstract function. Using DrRacketarrow_forwardWrite a function called set_plan(), which accepts, a string for a plan name, an integer for goal calories, and a pointer to an Excersie_plan. The function indirectly sets (via the pointer to the Excersie_plan) each component in the struct to the values passed into the function. The function does not return a value.arrow_forwardWrite a simple C++ program: A company implements a referal program that each customer will get bonus 5% of expense of thedirectly referred customer and 2% of all expenses of indirectly referred people. The list of connectedcustomers and expense of each customer is as belowPeter (1000) -> John (200) -> Harry (1200) -> Luna (400)a) Use singly linked list concepts to record those information. Write a function to print out the referralconnections in forward direction exactly as above.Hint: Define a class, e.g. namely Customer, with attributes are name, expense, bonus, *next.b) Write a function to find and print out the name of Customer with largest expense.c) Write a function namely updateBonus(Customer *head) to update and show the bonus values forall customers in the list.Sample Run:Peter (1000) -> John (200) -> Harry (1200) -> Luna (400)Customer with largest expense: HarryAll bonuses: Peter: 42 John: 68 Harry: 20arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author: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