Home / Expert Answers / Computer Science / can-you-write-this-code-in-java-thank-you-follows-same-program-grading-guidelines-as-program-sets-pa716

(Solved): CAN YOU WRITE THIS CODE IN Java thank you. - Follows same program grading guidelines as Program Sets ...



student submitted image, transcription available belowstudent submitted image, transcription available belowstudent submitted image, transcription available below

CAN YOU WRITE THIS CODE IN Java thank you.

- Follows same program grading guidelines as Program Sets - Do not need to show sample runs. Only submit .java or .cpp file. Write a program given a description of a family tree and pairs of people in the tree, determine the relationships between each pair of people. Suppose two people are named A and B and their closest common ancestor is named . One can say that is generations removed from if there are direct descendants from ending with . Thus, if is the daughter of , she is 1 generation removed; if she is the granddaughter of , she is 2 generations removed, and so on. Any person is generations removed from themselves. Now let be generations removed from and be generations removed from where . The following rules are used to determine the relationship between and : 1. if then is the child of if or the great grandchild of if . 2. if then and are siblings if or -th cousins if . 3. if then and are -th cousins times removed. Notice that if and one gets " 0 th cousins, 1 time removed" for the relationships typically described as "aunt/uncle" or "niece/nephew". The table below shows some more examples with two people named and : The input from a data file begins with a line containing two positive integers where and specify the number of tree descriptions described below and the number of query pairs. Following these are lines, each with one tree description. Each tree description will be of the form y indicating that person has children named through . All names will be unique and contain only alphabetic characters. Tree descriptions may be given in any order; thus, the root or entire tree may not be the first tree description. No name will appear more than once as in the tree descriptions. All the tree descriptions will combine to form exactly one tree, and the tree will have between nodes. Following this are lines of the form where and both names are found in the tree. Output to the screen, the relationship for each pair of people, one per line, using the format shown in the table above. Always output a's name first for each pair except when is the direct descendant of a like the first example in the table above. For the -th ordinal number output th except for output 1 st, 2 nd, 3rd, 21st, 22nd, 23rd, , etc. Also, output the word times for all times removed except one, otherwise use the word time. Let the user input the file name from the keyboard. Finally, the program should ask if the user wants to run the program again (Check case). Use a tree data structure. Refer to the sample output below. Name the program: FamilyGenerationsXX. java or FamilyGenerations XX.cpp, where XX are your initials. 45 Horatio 1 Irene Chris 2 Gina Horatio Alice 3 Dan Emily Frank Bob 2 Alice Chris Irene Bob Dan Frank Chris Emily Alice Chris Dan Irene


We have an Answer from Expert

View Expert Answer

Expert Answer



We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe