|
-
February 22nd, 2003, 07:34 PM
#1
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.
-
February 22nd, 2003, 08:10 PM
#2
You already posted this and I replied to the other post.
--Paul
-
February 22nd, 2003, 09:29 PM
#3
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?
-
February 22nd, 2003, 09:39 PM
#4
Well, does it definitely have to store the percentages? You could
print out the percentages as you know them and get the same
effect.
-
February 22nd, 2003, 10:58 PM
#5
No, I have to have formatted output at the end
Team-----2-pointers------3-pointers------Overall-----FreeThrows
CHS---------#/#=%--------#/#=%---------#/#=%------#/#=%
PHS -------SAME AS ABOVE------
-
February 22nd, 2003, 11:04 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|