You are to write a program that uses recursion to find all family ancestors and descendants...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You are to write a program that uses recursion to find all family ancestors and descendants of a given person. The program asks for the name of the family data file and then prompts for a specific person's name. If the person is in the family database, the program shows all the ancestors and all the descendants for that person. For ancestors it must show all parents, all grandparents, all great grandparents, etc. For descendants it must show all children, all grandchildren, all great grandchildren, etc. The program also must use indentation to make it clear who is a parent of whom and who is a child of whom. As a test data file, you will be using information about the Tudor kings and queens of England. The name of the file is "tudor.txt". Format of tudor.txt: The first section of the file (until the line with "END" has all the unique family members. The section of the tudor.txt after the "END" is divided into groups of three - first the family member, then his/her mother, then his/her father. This is how you can tell who is related to whom. i.e.: Arthur Family Member Elizabeth of York -> Mother Henry VII > Father Henry VIII > Family Member Elizabeth of York -> Mother Henry VII -> Father etc. Special cases: The data file contains no information prior to Henry VII, so when you ask for information about him, you get a lot of descendants but no ancestor information. Below is the log of execution you should obtain for him. What is the input file? tudor.txt Person's name ('quit' to end)? Henry VII Ancestors: Henry VII Descendants: Henry VII Arthur Henry VIII Mary I Elizabeth I Edward VI Margaret James V Mary Mary, Queen of Scots James VI & I Margaret Stuart Henry, Lord Darnley James VI & I Frances Descendants: At the other extreme is James VI of Scotland who became James I of England. The data file has no information about his descendants, but a great deal of information about his ancestors. Below is the log you should obtain for him. Lady Jane Grey What is the input file? tudor.txt Person's name ('quit' to end)? James VI & I Ancestors: James VI & I Mary, Queen of Scots Mary of Guise James V Margaret Elizabeth of York Henry VII Henry, Lord Darnley Margaret Stuart. James VI & I James IV Margaret Elizabeth of York Henry VII Your task: You are required to demonstrate that your program works for these two individuals and for another in the middle of this family tree. In particular, you should test it for Margaret. Below is the log you should obtain for her. What is the input file? tudor.txt Person's name ('quit' to end)? Margaret Ancestors: Margaret Elizabeth of York Henry VII Descendants: Margaret James V Mary, Queen of Scots James VI & I Margaret Stuart. Henry, Lord Darnley James VI & I Your client program should be named "Relatives.java" and it should include only static methods. It should prompt the use for the test file and then for the name of the person. If the name does not exist it should print a message and quit. If the name exists it should print the ancestors and descendants as shown in the above examples. Design Hints: Feel free to structure your program according to your preferences but remember that a crucial aspect of being a proficient software engineer is paying careful attention to the design of your program. Consider structuring your program to enable the client program to read the provided family file, store family information, and utilize recursive methods to print ancestors and descendants when given a person's name. Your grade will reflect the quality of your object-oriented design skills. Make sure that you're writing object-oriented code and that the ancestors and descendants are produced using recursive methods. You should also explain these methods in your README.txt file. You are to write a program that uses recursion to find all family ancestors and descendants of a given person. The program asks for the name of the family data file and then prompts for a specific person's name. If the person is in the family database, the program shows all the ancestors and all the descendants for that person. For ancestors it must show all parents, all grandparents, all great grandparents, etc. For descendants it must show all children, all grandchildren, all great grandchildren, etc. The program also must use indentation to make it clear who is a parent of whom and who is a child of whom. As a test data file, you will be using information about the Tudor kings and queens of England. The name of the file is "tudor.txt". Format of tudor.txt: The first section of the file (until the line with "END" has all the unique family members. The section of the tudor.txt after the "END" is divided into groups of three - first the family member, then his/her mother, then his/her father. This is how you can tell who is related to whom. i.e.: Arthur Family Member Elizabeth of York -> Mother Henry VII > Father Henry VIII > Family Member Elizabeth of York -> Mother Henry VII -> Father etc. Special cases: The data file contains no information prior to Henry VII, so when you ask for information about him, you get a lot of descendants but no ancestor information. Below is the log of execution you should obtain for him. What is the input file? tudor.txt Person's name ('quit' to end)? Henry VII Ancestors: Henry VII Descendants: Henry VII Arthur Henry VIII Mary I Elizabeth I Edward VI Margaret James V Mary Mary, Queen of Scots James VI & I Margaret Stuart Henry, Lord Darnley James VI & I Frances Descendants: At the other extreme is James VI of Scotland who became James I of England. The data file has no information about his descendants, but a great deal of information about his ancestors. Below is the log you should obtain for him. Lady Jane Grey What is the input file? tudor.txt Person's name ('quit' to end)? James VI & I Ancestors: James VI & I Mary, Queen of Scots Mary of Guise James V Margaret Elizabeth of York Henry VII Henry, Lord Darnley Margaret Stuart. James VI & I James IV Margaret Elizabeth of York Henry VII Your task: You are required to demonstrate that your program works for these two individuals and for another in the middle of this family tree. In particular, you should test it for Margaret. Below is the log you should obtain for her. What is the input file? tudor.txt Person's name ('quit' to end)? Margaret Ancestors: Margaret Elizabeth of York Henry VII Descendants: Margaret James V Mary, Queen of Scots James VI & I Margaret Stuart. Henry, Lord Darnley James VI & I Your client program should be named "Relatives.java" and it should include only static methods. It should prompt the use for the test file and then for the name of the person. If the name does not exist it should print a message and quit. If the name exists it should print the ancestors and descendants as shown in the above examples. Design Hints: Feel free to structure your program according to your preferences but remember that a crucial aspect of being a proficient software engineer is paying careful attention to the design of your program. Consider structuring your program to enable the client program to read the provided family file, store family information, and utilize recursive methods to print ancestors and descendants when given a person's name. Your grade will reflect the quality of your object-oriented design skills. Make sure that you're writing object-oriented code and that the ancestors and descendants are produced using recursive methods. You should also explain these methods in your README.txt file.
Expert Answer:
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these algorithms questions
-
In this programming assignment you will practice using ArrayLists, Inheritance and Polymorphism. You are to write a game called Magical Creatures War. You will do this by implementing a class called...
-
The organizing committee for the HCC Celebrates Columbia's 50th Birthday, Inc., has planned a special event commemorating notable people originally from Columbia, MD. The committee has invited the...
-
Passenger table (passengerid, address etc.) Flight table (flight id, departure, destination, depDate) Booking table (cID, fid, date, cost) a. Find Passengers who live in Chicago b. Total number of...
-
What is the orgazational culture defenition , history ?
-
One of the harmonic frequencies for a particular string under tension is 325Hz. The next higher harmonic frequency is 390 Hz. What harmonic frequency is next higher after the harmonic frequency 195...
-
Determine the work done in compressing \(1 \mathrm{~kg}\) of air from a volume of \(0.15 \mathrm{~m}^{3}\) at a pressure of \(1 \mathrm{bar}\) to a volume of \(0.05 \mathrm{~m}^{3}\), when the...
-
What costs would the New England Patriots have considered when analyzing the purchase of team planes and when pricing the rental of its team planes? The New England Patriots recently became the first...
-
List any four applications of KNN. Explain with Example
-
Problem 1. You have managed to learn all friendship connections in the social network Basehook (Bh). You want to forward a message from one person to another, but have observed that the impact of a...
-
Given that f(x)=5x+2, find (fo f)( -3).
-
7. Consider the rectangle of length and width 1, as shown. This rectangle is divided into two parts by the function y = sinx. What frac- tion of the area of the rectangle is in the shaded portion?...
-
Using Visual Basic for Applications (VBA), and only the input data given below, create a macro in Excel that calculates the Macauley's Duration for the given bond using a For Next loop. The inputs...
-
Briefly explain the meaning of the following terms as used in the law of succession. Donatio mortis causa. (ii) Partial intestacy. Kifo died on 12 March 2013, and by his will made in 2011, bequeathed...
-
Critically discuss the degree to which an understanding of environmental structures and processes should be included when planning the delivery and management of different types of infrastructure....
-
KC Restaurants Ltd. was incorporated on July 1, 2019, and began operations immediately. By December 31, 2019 (the corporations first year end), three new restaurants had been opened, two of which...
-
An access route is being constructed across a field (Figure Q8). Apart from a relatively firm strip of ground alongside the field's longer side AB, the ground is generally marshy. The route can...
-
Write code to read a dictionary from a file, then prompt the user for two words and tell the user how many words in the dictionary fall between those two words. Here is a sample run of the program:...
-
What is the output of the following program? (You may wish to draw a structure diagram first.) public class Confusing { public static void method2 () { method1 (); System.out.println ("I am method...
-
Write a reverse Hangman game in which the user thinks of a word and the computer tries to guess the letters in that word. The user tells the computer how many letters the word contains.
-
Maximum work is done in compressing air when the compression is: (a) Isothermal compression (b) Adiabatic compression (c) Polytropic compression (d) None of these
-
A single stage single acting air compressor has intake pressure 1 bar and delivery pressure 10 bar. The compression and expansion follow the law \(\mathrm{pV}^{1.3}=\) constant. The piston speed and...
-
Derive the expression of work done by the compressor in isothermal compression, adiabatic compression, and polytropic compression.
Study smarter with the SolutionInn App