Program that scores the following data about soccer player in a structure (C++)
Has the Isbell–Freyd criterion ever been used to check that a category is concretisable?
What is the difference between ashamed and shamed?
Is there any relevance to Thor getting his hair cut other than comedic value?
When should a commit not be version tagged?
Significance and timing of "mux scans"
Which aircraft had such a luxurious-looking navigator's station?
How do ISS astronauts "get their stripes"?
Six real numbers so that product of any five is the sixth one
How can atoms be electrically neutral when there is a difference in the positions of the charges?
Should I choose Itemized or Standard deduction?
Did 5.25" floppies undergo a change in magnetic coating?
Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?
How to count occurrences of Friday 13th
What type of postprocessing gives the effect of people standing out
How can I handle a player who pre-plans arguments about my rulings on RAW?
Closure of presentable objects under finite limits
Does music exist in Panem? And if so, what kinds of music?
Is divide-by-zero a security vulnerability?
Can you use a beast's innate abilities while polymorphed?
How can I be pwned if I'm not registered on that site?
Understanding Kramnik's play in game 1 of Candidates 2018
Are small insurances worth it
How to tighten battery clamp?
Can I become debt free or should I file for bankruptcy? How do I manage my debt and finances?
Program that scores the following data about soccer player in a structure (C++)
$begingroup$
I am coming for a code review checkup from you C++ experts to review my code if I am not using these restrictions shown below:
- No global variables
- No labels or go-to statements
No infinite loops, examples include:
- for(;;)
- while(1)
- while(true)
- do{//code}while(1);
- No break statements to exit loops
Here is my code:
#include <iostream>
using namespace std;
//MARK: Declaration of the Player's structure.
struct Player {
//MARK: Player's name
char playerName[100]; // I either can array of 45 or 100. But, I choose array of 100.
//MARK: Player's number
int playerNumber;
//MARK: Points scored by the player.
int playerPoints;
};
int main() {
int error = 1;
int highestScore = 0;
struct Player players[12];
int index;
for (index = 0; index < 12; index++) {
//MARK: Displaying player number.
cout << "nPLAYER #" << (index + 1) << "n";
cout << "n Player name:";
cin >> players[index].playerName;
while (error == 1) {
cout << "n Player's number:";
cin >> players[index].playerNumber;
//MARK: Simple validation to detect the player for entering negative numbers.
if (players[index].playerNumber < 0) {
cout << "n No negative numbers pleasen";
continue;
}
cout << "n Points scored: ";
cin >> players[index].playerPoints;
if (players[index].playerPoints < 0) {
cout << "n No negative numbers pleasen";
continue;
}
cin.clear();
error = 0;
}
error = 1;
}
//MARK: Display players table.
cout << "NAMEtNUMBERtPOINTS SCOREDn";
// MARK: Iterate through our 12 players.
for (index = 0; index < 12; index++) {
cout << index << " " << players[index].playerName
<< "t" << players[index].playerNumber << "t" <<
players[index].playerPoints << endl;
}
// MARK: Calculate the total points earned by the soccer team.
int totalPoints = 0;
for (index = 0; index < 12; index++)
totalPoints += players[index].playerPoints;
//MARK: Find the player with maximum points.
for (index = 0; index < 12; index++) {
if (players[index].playerPoints > players[highestScore].playerPoints)
highestScore = index;
}
//MARK: Displaying the results.
cout << "n TOTAL POINTS: " << totalPoints << endl;
cout << "The player who scored the most points is:";
cout << players[highestScore].playerName << endl;
return 0;
}
c++
New contributor
Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
I am coming for a code review checkup from you C++ experts to review my code if I am not using these restrictions shown below:
- No global variables
- No labels or go-to statements
No infinite loops, examples include:
- for(;;)
- while(1)
- while(true)
- do{//code}while(1);
- No break statements to exit loops
Here is my code:
#include <iostream>
using namespace std;
//MARK: Declaration of the Player's structure.
struct Player {
//MARK: Player's name
char playerName[100]; // I either can array of 45 or 100. But, I choose array of 100.
//MARK: Player's number
int playerNumber;
//MARK: Points scored by the player.
int playerPoints;
};
int main() {
int error = 1;
int highestScore = 0;
struct Player players[12];
int index;
for (index = 0; index < 12; index++) {
//MARK: Displaying player number.
cout << "nPLAYER #" << (index + 1) << "n";
cout << "n Player name:";
cin >> players[index].playerName;
while (error == 1) {
cout << "n Player's number:";
cin >> players[index].playerNumber;
//MARK: Simple validation to detect the player for entering negative numbers.
if (players[index].playerNumber < 0) {
cout << "n No negative numbers pleasen";
continue;
}
cout << "n Points scored: ";
cin >> players[index].playerPoints;
if (players[index].playerPoints < 0) {
cout << "n No negative numbers pleasen";
continue;
}
cin.clear();
error = 0;
}
error = 1;
}
//MARK: Display players table.
cout << "NAMEtNUMBERtPOINTS SCOREDn";
// MARK: Iterate through our 12 players.
for (index = 0; index < 12; index++) {
cout << index << " " << players[index].playerName
<< "t" << players[index].playerNumber << "t" <<
players[index].playerPoints << endl;
}
// MARK: Calculate the total points earned by the soccer team.
int totalPoints = 0;
for (index = 0; index < 12; index++)
totalPoints += players[index].playerPoints;
//MARK: Find the player with maximum points.
for (index = 0; index < 12; index++) {
if (players[index].playerPoints > players[highestScore].playerPoints)
highestScore = index;
}
//MARK: Displaying the results.
cout << "n TOTAL POINTS: " << totalPoints << endl;
cout << "The player who scored the most points is:";
cout << players[highestScore].playerName << endl;
return 0;
}
c++
New contributor
Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
I am coming for a code review checkup from you C++ experts to review my code if I am not using these restrictions shown below:
- No global variables
- No labels or go-to statements
No infinite loops, examples include:
- for(;;)
- while(1)
- while(true)
- do{//code}while(1);
- No break statements to exit loops
Here is my code:
#include <iostream>
using namespace std;
//MARK: Declaration of the Player's structure.
struct Player {
//MARK: Player's name
char playerName[100]; // I either can array of 45 or 100. But, I choose array of 100.
//MARK: Player's number
int playerNumber;
//MARK: Points scored by the player.
int playerPoints;
};
int main() {
int error = 1;
int highestScore = 0;
struct Player players[12];
int index;
for (index = 0; index < 12; index++) {
//MARK: Displaying player number.
cout << "nPLAYER #" << (index + 1) << "n";
cout << "n Player name:";
cin >> players[index].playerName;
while (error == 1) {
cout << "n Player's number:";
cin >> players[index].playerNumber;
//MARK: Simple validation to detect the player for entering negative numbers.
if (players[index].playerNumber < 0) {
cout << "n No negative numbers pleasen";
continue;
}
cout << "n Points scored: ";
cin >> players[index].playerPoints;
if (players[index].playerPoints < 0) {
cout << "n No negative numbers pleasen";
continue;
}
cin.clear();
error = 0;
}
error = 1;
}
//MARK: Display players table.
cout << "NAMEtNUMBERtPOINTS SCOREDn";
// MARK: Iterate through our 12 players.
for (index = 0; index < 12; index++) {
cout << index << " " << players[index].playerName
<< "t" << players[index].playerNumber << "t" <<
players[index].playerPoints << endl;
}
// MARK: Calculate the total points earned by the soccer team.
int totalPoints = 0;
for (index = 0; index < 12; index++)
totalPoints += players[index].playerPoints;
//MARK: Find the player with maximum points.
for (index = 0; index < 12; index++) {
if (players[index].playerPoints > players[highestScore].playerPoints)
highestScore = index;
}
//MARK: Displaying the results.
cout << "n TOTAL POINTS: " << totalPoints << endl;
cout << "The player who scored the most points is:";
cout << players[highestScore].playerName << endl;
return 0;
}
c++
New contributor
Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
I am coming for a code review checkup from you C++ experts to review my code if I am not using these restrictions shown below:
- No global variables
- No labels or go-to statements
No infinite loops, examples include:
- for(;;)
- while(1)
- while(true)
- do{//code}while(1);
- No break statements to exit loops
Here is my code:
#include <iostream>
using namespace std;
//MARK: Declaration of the Player's structure.
struct Player {
//MARK: Player's name
char playerName[100]; // I either can array of 45 or 100. But, I choose array of 100.
//MARK: Player's number
int playerNumber;
//MARK: Points scored by the player.
int playerPoints;
};
int main() {
int error = 1;
int highestScore = 0;
struct Player players[12];
int index;
for (index = 0; index < 12; index++) {
//MARK: Displaying player number.
cout << "nPLAYER #" << (index + 1) << "n";
cout << "n Player name:";
cin >> players[index].playerName;
while (error == 1) {
cout << "n Player's number:";
cin >> players[index].playerNumber;
//MARK: Simple validation to detect the player for entering negative numbers.
if (players[index].playerNumber < 0) {
cout << "n No negative numbers pleasen";
continue;
}
cout << "n Points scored: ";
cin >> players[index].playerPoints;
if (players[index].playerPoints < 0) {
cout << "n No negative numbers pleasen";
continue;
}
cin.clear();
error = 0;
}
error = 1;
}
//MARK: Display players table.
cout << "NAMEtNUMBERtPOINTS SCOREDn";
// MARK: Iterate through our 12 players.
for (index = 0; index < 12; index++) {
cout << index << " " << players[index].playerName
<< "t" << players[index].playerNumber << "t" <<
players[index].playerPoints << endl;
}
// MARK: Calculate the total points earned by the soccer team.
int totalPoints = 0;
for (index = 0; index < 12; index++)
totalPoints += players[index].playerPoints;
//MARK: Find the player with maximum points.
for (index = 0; index < 12; index++) {
if (players[index].playerPoints > players[highestScore].playerPoints)
highestScore = index;
}
//MARK: Displaying the results.
cout << "n TOTAL POINTS: " << totalPoints << endl;
cout << "The player who scored the most points is:";
cout << players[highestScore].playerName << endl;
return 0;
}
c++
c++
New contributor
Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 2 mins ago
MikeMike
6
6
New contributor
Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "196"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Mike is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f214736%2fprogram-that-scores-the-following-data-about-soccer-player-in-a-structure-c%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Mike is a new contributor. Be nice, and check out our Code of Conduct.
Mike is a new contributor. Be nice, and check out our Code of Conduct.
Mike is a new contributor. Be nice, and check out our Code of Conduct.
Mike is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f214736%2fprogram-that-scores-the-following-data-about-soccer-player-in-a-structure-c%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown