-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdec15.cpp
More file actions
94 lines (73 loc) · 1.91 KB
/
dec15.cpp
File metadata and controls
94 lines (73 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;
struct NBA
{
string nameOfPlayer;
int numberOfPlayer;
int pointsScored;
};
int const SIZE = 3;
void getInfo(NBA players[]);
void showInfo(NBA players[]);
void showHighest(NBA players[]);
int getTotal(NBA players[]);
int main()
{
NBA player[SIZE];
getInfo(player);
showInfo(player);
cout << "The total is " << getTotal(player) << endl;
showHighest(player);
return 0;
}
int getTotal(NBA players[])
{
int total = 0;
for(int i = 0; i < SIZE; i++)
{
total += players[i].pointsScored;
}
return total;
}
void showInfo(NBA players[])
{
for(int i = 0; i < SIZE; i++)
{
cout << endl;
cout << "Player #: " << i + 1 << endl;
cout << "==================" << endl;
cout << "The Player's name is: " << players[i].nameOfPlayer << endl;
cout << "The players number is " << players[i].numberOfPlayer<< endl;
cout << "The Player Points Scored was: " << players[i].pointsScored;
cout << endl;
}
}
void getInfo(NBA players[])
{
for(int i = 0; i < SIZE; i++)
{
cout << "Please enter the player's name: " << endl;
cin.ignore();
getline(cin, players[i].nameOfPlayer);
cout << "Please enter the player's numbers: " << endl;
cin >> players[i].numberOfPlayer;
cout << "Please enter the player points scored: " << endl;
cin >> players[i].pointsScored;
}
}
void showHighest(NBA players[])
{
int highest = 0;
for(int i = 0; i < SIZE; i++)
{
int highestPoint = players[0].pointsScored;
if(players[i].pointsScored > highestPoint )
{
highest = players[i].pointsScored;
}
}
cout << "The playe who scored the most point " << players[highest].nameOfPlayer << endl;
}