Transcribed TextTranscribed Text

HW 1: Define the struct Course that has the components code, title, credits, and grade. Define the class Student that has the private data members id, name, numberOfCourses, listOfCourses[ ], and GPA. The class has the public member functions set( ), get( ). print( ), and default parameterized constructor. The class also has the private member function calculateGPA(). Implement the class members, and use the following driver: int main() { Student someone; someone.set("U1712345", "Ali Omar", 2); someone.print(); return 0; ) Sample input / output: Enter the course code, and title: 1411116 Programming I Enter the course credits, and grade: 4 C Enter the course code, and title: 1411211 Programming II Enter the course credits, and grade: 3 B The student U1712345 Ali Omar studied the following 2 courses: 1411116 Programming I 4 c 1411211 Programming II 3 B The student GPS is 2.42857 HW2: Define a class Player with private data members name, (of type string), id, payRate (of type integer). The class has the member functions set( ) print( ). getPayRate( ). getName( ) and parameterized constructor with default values. The following is list of famous volleyball players and their pay rates per game: id pay rate name 111 630 Karch Kiraly 112 790 Logan Tom 131 420 Misty May Treanor 142 580 Kerri Walsh 144 610 Steve Timmons 152 1100 Paula Weishoff 156 390 Ron Von Hagen 157 750 Flo Hyman 181 810 Mike Whitmarsh Define a class Team with protected data members numberOfPlayers (of type integer), salaries (of type integer calculated as the total pay rate of the team players), list[ ] (array of elements of type Player). The class has the member functions set( ). print( ). calculate Teamsalaries( ,getSalaries( ). and parameterized constructor with default value 1 for the number of flayers. The function set( ) reads the ids of a number of players in ascending order then it uses a switch statement to assign values to the three data members of each player. Define the class Match which publicly inherits the class Team. The class has the private data members numberOfGames, numberOfPoints, cost (of type int). The class has the public member functions set( ). print( ). calculateTotalCost( ). and a default parameterized constructor with default values. Each point is worth 2500, so the cost is calculated using the formula cost numberOfGames salaries 2500 * numberOfPoints If the value of cost is positive then the club lost money, while if cost is negative then the club gain moncy. Implement the member functions of all classes enforcing the least privileged principle. The following driver produces the given sample of input / output: int main() { Match one(3, 2, 5); onc.print(): return 0; ) Sample input / output: Enter the id of all players in ascending order: 111 142 156 The team has the following 3 players: The pay rate of player Karch Kiraly is 630 The pay rate of player Kerri Walsh is 580 The pay rate of player Ron Von Hagen is 398 The team total salaries is 1600 The team played 2 games and scored 5 points. The team gained 9380 dirham

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include "Team.h"

void Team::set(int teamNumberOfPlayers) {
int id; // variable to hold the temporary player id
int idx = 0; // variable to hold the index of the players list

// check the validity of the value of teamNumberOfPlayers variable
if(teamNumberOfPlayers < 0) {
    // if not valid, set to 0
    cout << "The number of players cannot be negative. It will be set to 0" << endl;
    numberOfPlayers = 0;
else {
    // else, store the teamNumberOfPlayers to class field numberOfPlayers
    numberOfPlayers = teamNumberOfPlayers;

// prompt the user to enter the player ids
cout << "Enter the id of all players in ascending order: ";
for (int i = 0; i < teamNumberOfPlayers; i++) {
    // get the id
    cin >> id;
    // for every valid id, add corresponding player with data from the table
    switch(id) {
    case 111:
      list[idx++] = Player("Karch Kiraly", id, 630);
    case 112:
      list[idx++] = Player("Logan Tom", id, 790);
    case 131:
      list[idx++] = Player("Misty May Treanor", id, 420);
    case 142:
      list[idx++] = Player("Kerri Walsh", id, 580);
    case 144:
      list[idx++] = Player("Steve Timmons", id, 610);
    case 152:
      list[idx++] = Player("Paula Weishoff", id, 1100);
    case 156:
      list[idx++] = Player("Ron Von Hagen", id, 390);
    case 157:
      list[idx++] = Player("Flo Hyman", id, 750);
    case 181:
      list[idx++] = Player("Mike Whitmarsh", id, 810);
      // if wrong id is entered, print the message and decrement the numberOfPlayers
      cout << "No player with id " << id << ". Skipping the player..." << endl;

By purchasing this solution you'll be able to access the following files: and

50% discount

$40.00 $20.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats