133k views
1 vote
Write a C++ coding for a beginner programming student based on question below

Write a C++ coding for a beginner programming student based on question below-example-1
User DashK
by
7.8k points

1 Answer

4 votes

The provided snippet outlines the structure for a C++ program to calculate and display individual and team scores in a bowling competition. The program includes creating structures for players and teams, and will require functions for input, sorting, and calculating scores following the given criteria.

Writing a C++ program for a beginner to solve the described problem involves handling multiple actions such as storing scores, calculating totals for teams, and outputting various results. Note that the code will be simplified for educational purposes. A possible C++ code snippet is provided below:

include <iostream>

#include <string>

#include <vector>

#include <algorithm>

using namespace std;

struct Player {

string name;

int score;

};

struct Team {

string name;

vector<Player> players;

};

// Function prototypes and any additional functions go here

int main() {

// Initialize teams and players

// Collect scores and names

// Calculate team scores, individual winner, winning team

// Output teams with more than 600 points

// Obtain and output a player's score based on input name

// Calculate and output the average score for a team based on input name

return 0;

}

The above code structure sets the foundation but does not contain the implementation details which should include functions to:

  • Read players' names and scores
  • Sort and calculate team scores based on the given formula
  • Determine the individual winner (highest score) and the winning team (highest team score)
  • Progress through the teams and output those with scores over 600
  • Search for a player's score by name
  • Calculate and output the average score for a team

For a beginners' level program, it is crucial to focus on basic input/output, sorting, and looping constructs in C++. The actual coding requires further steps including loops for input, sorting scores within teams, calculating totals, and comparing scores to determine winners.

User KingMak
by
8.1k points