CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2002
    Posts
    30

    question about user-defined functions

    As an assignment, I have to write a program that records stats to a basketball game for a team and their opponent . I MUST include a function called point_shoot to find the shooting percent (2 pointers made/ 2 pointers attempted) for 2 pointers, 3 pointers, free throws, and overall. The function point_shoot must be called multiple times in the program. My output must have this (example)

    Team---------2 pointers----------3 pointers--------Overall---------Freethrows
    AHS---------9/11=81.81%----------2/3 =66.67%--------etc.
    PHS---------6/15=40.0%----------3/6= 50.0%

    I am confused as to how I can call the point_shoot function multiple times and have it store each set of input to be able to output the percentages for AHS 2 pointers, 3 pointers etc. and PHS 2 pointers, 3 pointers, etc.

    I am a beginner at C++ and just learned user-defined functions.

    Thanks
    Last edited by gurlygurlz; February 22nd, 2003 at 07:39 PM.

  2. #2
    Join Date
    May 2000
    Location
    Phoenix, AZ [USA]
    Posts
    1,347
    You already posted this and I replied to the other post.
    --Paul

  3. #3
    Join Date
    Oct 2002
    Posts
    30
    i know but i do not understand...

    how is it going to keep track of 2pointers, 3 pointers etc. for each team so that i can output it all at the end. wouldnt it write over the first input when i input the second made and attempted?

  4. #4
    Join Date
    May 2000
    Location
    Phoenix, AZ [USA]
    Posts
    1,347
    Well, does it definitely have to store the percentages? You could
    print out the percentages as you know them and get the same
    effect.

  5. #5
    Join Date
    Oct 2002
    Posts
    30
    No, I have to have formatted output at the end

    Team-----2-pointers------3-pointers------Overall-----FreeThrows
    CHS---------#/#=%--------#/#=%---------#/#=%------#/#=%
    PHS -------SAME AS ABOVE------

  6. #6
    Join Date
    May 2000
    Location
    Phoenix, AZ [USA]
    Posts
    1,347
    Well there you go

    Just modify the routine I gave you earlier so that you pass in the
    high school name too. Then alter the cout statements so that
    you are printing in the style you need.

    The main thing to keep in mind is that you don't want global
    variables all over the place; the method you were using was
    prohibiting the easy reuse of functions.

    --Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured