Question

In: Computer Science

Instructions: program in C++, add pseudocode and comment throughout the program. Assignment: Create a program to...

Instructions: program in C++, add pseudocode and comment throughout the program.

Assignment:

Create a program to keep track of the statistics for a kid’s soccer team. The program will have a structure that defines what data the program will collect for each of the players.

The structure will keep the following data:

  • Players Name (string)
  • Players Jersey Number (integer)
  • Points scored by Player (integer)

The program will have an array of 12 players (use less for testing and development, use a constant for the size). Each element in the array is a different player on the team.

The program will ask the user to enter information for each player. The program will also display the team information in a table format. After the table, the total points scored by a team will be displayed.

The program will also determine which player scored the most points on the team.

Validation:

  • Do not accept negative value for player’s number
  • Do not accept negative value for player’s score

Required Methods:

  • void GetPlayerInfo(Player &);
  • void ShowPlayerInfo(const Player);
  • int GetTotalPoints(const Player[ ], int);
  • void ShowHighest(Player [ ], int);

Solutions

Expert Solution

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
using namespace std;

struct Player
{
string name;
   int jerseyNum;
   int points;  
};

void GetPlayerInfo(Player &p);
void ShowPlayerInfo(const Player p);
int GetTotalPoints(const Player p[], int size);
void ShowHighest(Player p[], int size);

int main() {
const int SIZE=12;

Player p[SIZE];

for(int i=0;i<SIZE;i++)
{
    cout<<"Player"<<(i+1)<<"::"<<endl;
    GetPlayerInfo(p[i]);
    cin.ignore();
}

for(int i=0;i<SIZE;i++)
{
    ShowPlayerInfo(p[i]);
}

int tot=GetTotalPoints(p,SIZE);
cout<<"Total Points :"<<tot<<endl;
ShowHighest(p,SIZE);


   return 0;
}
void GetPlayerInfo(Player &p)
{
  
    cout<<"Enter name :";
    getline(cin,p.name);
    while(true)
    {
        cout<<"Enter jersey number :";
    cin>>p.jerseyNum;
    if(p.jerseyNum<0)
    {
        cout<<"** Invalid.Must be positive **"<<endl;
       }
       else
       break;
   
       }
    while(true)
    {
        cout<<"Enter points :";
    cin>>p.points;
    if(p.points<0)
    {
        cout<<"** Invalid.Must be positive **"<<endl;
       }
       else
       break;
   
       }
}
void ShowPlayerInfo(const Player p)
{
   cout<<setw(15)<<left<<p.name<<setw(6)<<right<<p.jerseyNum<<setw(6)<<right<<p.points<<endl;
}
int GetTotalPoints(const Player p[], int size)
{
   int tot=0;
   for(int i=0;i<size;i++)
   {
       tot+=p[i].points;
   }
}
void ShowHighest(Player p[], int size)
{
   int max=p[0].points;
   int maxIndx=0;
   for(int i=0;i<size;i++)
   {
       if(max<p[i].points)
       {
           max=p[i].points;
           maxIndx=i;
       }
   }
  
   cout<<"Highest Points "<<max<<" is earned by "<<p[maxIndx].name<<endl;
  
  
}

____________________________

Output:

_______________Could you plz rate me well.Thank You


Related Solutions

In C++ Complete the template program. ADD to your c++ program as a comment the PARTIAL...
In C++ Complete the template program. ADD to your c++ program as a comment the PARTIAL output from executing your program - Only copy the last 6 lines of output. There is no input data for this problem. // Find Pythagorean triples using brute force computing. #include <iostream> using std::cout; using std::endl; int main() { int count = 0; // number of triples found long int hypotenuseSquared; // hypotenuse squared long int sidesSquared; // sum of squares of sides cout...
For this assignment you will develop pseudocode and write a C++ program for a simple calculator....
For this assignment you will develop pseudocode and write a C++ program for a simple calculator. You will create both files in Codio. Put your pseudocode and C++ code in the files below. PSEUDOCODE FILE NAME: Calculator.txt C++ SOURCE CODE FILE NAME : Calculator.cpp DESCRIPTION: Write a menu-driven program to perform arithmetic operations and computations on a list of integer input values. Present the user with the following menu. The user will choose a menu option. The program will prompt...
Create a C program that performs the following (please comment the codes): a) Create a Stack...
Create a C program that performs the following (please comment the codes): a) Create a Stack ADT. Stack should be implemented using the linked list. b) Enter 10 random integer numbers between 0 to 50 in the stack. c) After pushing each element, print the content of the top of the stack. c) Then pop out those 10 integer numbers and print those numbers. d) Finally destroy the Stack.
C++ For this assignment, you will write a C++ program to either add (A), subtract (S),...
C++ For this assignment, you will write a C++ program to either add (A), subtract (S), multiply (M), and (N), or (O) two matrices if possible. You will read in the dimensions (rows, then columns) of the first matrix, then read the first matrix, then the dimensions (rows then columns) of the second matrix, then the second matrix, then a character (A, S, M, N, O) to determine which operation they want to do. The program will then perform the...
C++ programming Instructions Create a ShopCart class that allows you to add items to a shopping...
C++ programming Instructions Create a ShopCart class that allows you to add items to a shopping cart and get the total price of purchases made. Items are simply described by an Item class as follows: class Item {   public:      std :: String description;      float price; }; The ShopCart class must be able to add and remove items and display an invoice. This class must use a dynamically allocated array of items whose capacity is fixed in advance to the build....
Program Assignment 1 C++ please Instructions This assignment will require the use of three arrays, which...
Program Assignment 1 C++ please Instructions This assignment will require the use of three arrays, which will be used in parallel. Create a program that keeps track of the sales of BBQ sauces for a company. The company makes several different types of sauces, Original, Sticky Sweet, Spicy, Sweet Heat, Hickory Bourbon and Smokey Mesquite. One array will contain the names of the different BBQ sauces. This array will be initialized from a text file with the 6 different names....
1. Create a console program in C#, * Create a class: "Student.cs" * Add 3 variables:...
1. Create a console program in C#, * Create a class: "Student.cs" * Add 3 variables: StudentName (string), SchoolYear (int), YearsUntilGraduation(int) * Method YTK() = 12 - SchoolYear; 2. Main *Enter name *Enter age *You will attend school:____ years before graduating.
write pseudocode for the following problems not c code Pseudocode only Write a C program to...
write pseudocode for the following problems not c code Pseudocode only Write a C program to print all natural numbers from 1 to n. - using while loop Write a C program to print all natural numbers in reverse (from n to 1). - using while loop Write a C program to print all alphabets from a to z. - using while loop Write a C program to print all even numbers between 1 to 100. - using while loop...
C Program and pseudocode for this problem. Write a C program that plays the game of...
C Program and pseudocode for this problem. Write a C program that plays the game of "Guess the number" as the following: Your program choose the number to be guessed by selecting an integer at random in the rang of 1 to 1000. The program then asks the use to guess the number. If the player's guess is incorrect, your program should loop until the player finally gets the number right. Your program keeps telling the player "Too High" or...
Instructions Write a program in C++ that create a LookupNames project. In the main function: Ask...
Instructions Write a program in C++ that create a LookupNames project. In the main function: Ask the user to enter a number of names, X to quit input. Store the names in an array. Also use a counter variable to count the number of names entered. Write a function displayNames to display the names. The function must receive the array and the counter as parameters. Write a function called lookupNames. The function must receive the array and the counter as...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT