1 #include <iostream>
2
3 using namespace std;
4
5 struct free_throws
6 {
7 string name;
8 int made;
9 int attempts;
10 float percent;
11 };
12
13 void set_pc(free_throws &ft);
14 void display(const free_throws &ft);
15 free_throws & accumlate(free_throws &target,const free_throws &source);
16 int main()
17 {
18 free_throws one = {"Rick",13,14};
19 free_throws two = {"jack",10,16};
20 free_throws three = {"Rose",11,13};
21 free_throws four = {"Mike",12,17};
22 free_throws team = {"Class 6",0,0};
23 set_pc(one);
24 display(one);
25 accumlate(accumlate(accumlate(accumlate(team,one),two),three),four);
26 display(team);
27 return 0;
28 }
29
30 void set_pc(free_throws &ft)
31 {
32 if(ft.attempts != 0)
33 ft.percent = 100.0 * float(ft.made) / float(ft.attempts);
34 else
35 ft.attempts = 0;
36 }
37
38 void display(const free_throws &ft)
39 {
40 cout << "Name: " << ft.name << endl;
41 cout << "Made: " << ft.made << "\t";
42 cout << "Attempt: " << ft.attempts << "\t";
43 cout << "Percent: " << ft.percent << endl;
44 }
45
46 free_throws & accumlate(free_throws &target,const free_throws &source)
47 {
48 target.attempts += source.attempts;
49 target.made += source.made;
50 set_pc(target);
51 return target;
52 }
![]()