Visual Programming.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lady dyna
    New Member
    • Mar 2007
    • 6

    #1

    Visual Programming.

    Question Details:

    Maintain a family tree and output family data in correct order.

    Details

    To solve this problem you have to:

    Declare structure named Family that has following eight members:

    Structure Family

    member of type Description

    dob Structure Date Date of Birth

    name character array of size 20 Name

    father character array of size 20 Father’s name

    mother character array of size 20 Mother’s name

    next Structure Family pointer Pointer to next structure

    previous Structure Family pointer Pointer to previous structure

    p_to_father Structure Family pointer Pointer to father structure

    p_to_mother Structure Family pointer Pointer to mother structure





    Structure Date

    member of type

    day integer

    month integer

    year integer

    Define a function (say get_personInfo) to take input of family members.

    Arguments no arguments

    Return type a pointer to a Family Structure.

    Within the function

    Define a pointer to Family type Structure (say temp) and allocate it memory by calling malloc()

    Take following input from user:

    Name of Person, Date of Birth, Father’s name, Mother’s name

    and store this information into temp and return temp.

    Define a function (say related) to fill in pointers to mother or father relationship

    Arguments two pointers to Family Structure (say first person and second person)

    Return type true or false



    Within the function

    call set_relationshi p twice to test all possibilities of relationship. That is:

    return set_relationshi p(first person, second person) || set_relationshi p(second person, first person)

    set_relationshi p()

    Arguments two pointers to Family Structure (say first person and second person)

    Return type true or false

    Within the function

    if first person’s father is equal to second person’s name

    first person’s p_to_father = second person

    return true

    if first person’s mother is equal to second person’s name

    first person’s p_to_mother = second person

    return true

    otherwise

    return false

    The main() function

    Declarations:

    name of type Description


    first Structure Family pointer Pointer to first person

    current Structure Family pointer Pointer to current person

    last Structure Family pointer Pointer to last person

    input char input character Y or N

    /* take input from user */

    infinite loop

    printf “Do you want to enter details of a person (Y or N)? ”

    scanf input

    if input is n

    break the loop

    current = get_personInfo( )

    if first == NULL

    first = current

    last = current

    else

    last->next = current

    current->previous = last

    last = current

    /* check and set the person’s relationships */

    Point current to the first

    loop until current->next is not NULL

    declare a parent count of type int local to this block

    point last to current->next

    loop until last is not NULL

    if related(current , last)

    if(++parent == 2)

    break the inner loop

    last = last->next

    current = current->next

    /* Output family data in correct order */

    Iterate through the list and print person’s name, birth day, birth month, birth year

    and also parent’s information i.e.; name, birth day, birth month, birth year

    /* Free the memory allocated through malloc() */

    Iterate through the list and call

    free(current)

    Sample Output

    Do you want to enter details of a person (Y or N)? y

    Enter person name: ABC

    Enter ABC’s date of birth (day month year): 2 2 70

    Enter ABC’s father name: DEF

    Enter ABC’s mother name: GHI

    Do you want to enter details of a person (Y or N)? y

    Enter person name: JKL

    Enter JKL’s date of birth (day month year): 4 4 74

    Enter JKL’s father name: MNO

    Enter JKL’s mother name: PQR

    Do you want to enter details of a person (Y or N)? y

    Enter person name: STU

    Enter STU’s date of birth (day month year): 6 6 96

    Enter STU’s father name: ABC

    Enter STU’s mother name: JKL

    Do you want to enter details of a person (Y or N)? n





    ABC was born in 2/2/70, and has DEF and GHI as parents.

    JKL was born in 4/4/74, and has MNO and PQR as parents.

    STU was born in 6/6/96, and has ABC and JKL as parents.

    ABC’s Birth date is 2/2/70 and JKL’s birth date is 4/4/74.
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Hello Lady dyna!

    Sounds like a wonderful project, I wish you luck in it. Would you mind adding your code, if you have it? Just in case anyone here would like to take a shot at it...

    Welcome!

    Dököll

    Comment

    • SammyB
      Recognized Expert Contributor
      • Mar 2007
      • 807

      #3
      I agree with Dököll, it sounds like a wonderful project. But, what is your question? On the remote chance that you wanted me to write a solution, you should know that I charge $100 per hour. If you have a question, then be sure to make it specific and short. Also, please tell us what VB you are using: VB.NET 2003, VB.NET 2005, VB6, or VBA. Thanks! --Sam

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        As a Moderator (there’s more than one), I feel I should clarify the position of TheScripts. We are all volunteers who help out because we like to, for whatever reasons. We don't charge for answers. (In fact we can't, the site doesn't even have any sort of payment mechanism, as far as I'm aware.)

        What I think SammyB was hinting at is the fact that we expect people to make a serious attempt at writing their own program, and post specific questions here if they get stuck. We're not a programming school, or a software development firm. Of course, once you do have a specific programming question, we’ll be glad to help.

        One more thing. Considering the apparent nature of your question, I feel I should draw your attention to the posting guidelines – specifically the section on Posting Homework or Coursework Questions and Answers.

        Comment

        Working...