7.23 LAB - Winning team (classes) Given main(), define the Team class (in files Team.h and Team.cpp). For class member f
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
7.23 LAB - Winning team (classes) Given main(), define the Team class (in files Team.h and Team.cpp). For class member f
7.23 LAB - Winning team (classes) Given main(), define the Team class (in files Team.h and Team.cpp). For class member function GetWinPercentage(), the formula is: wins / (wins + losses). Note: Use casting to prevent integer division. For class member function PrintStanding(), output the win percentage of the team with two digits after the decimal point and whether the team has a winning or losing average. A team has a winning average if the win percentage is 0.5 or greater. Ex: If the input is Ravens 133, where Ravens is the team's name, 13 is the number of team wins, and 3 is the number of team losses, the output is: Win percentage: 0.81 Congratulations, Team Ravens has a winning average! Ex: If the input is Angels 80 82, the output is: Win percentage: 0.49 Team Angels has a losing average. 200506.2440904.qx3zqy7 LAB ACTIVITY 1 #ifndef TEAMH 2 #define TEAMH 3 4 #include <string> 5 6 using namespace std; 7 8 9 7.23.1: LAB - Winning team (classes) 10 11 12 13 14 class Team { public: 15 16 3: std::string name; int wins, losses; Current file: Team.h - main.cpp Team.h Team.cpp float GetWinPercentage(int wins, int losses); void printname(); 0/20 Load default template...
7.23 LAB - Winning team (classes) Given main(), define the Team class (in files Team.h and Team.cpp). For class member function GetWinPercentage(), the formula is: wins / (wins + losses). Note: Use casting to prevent integer division. For class member function PrintStanding(), output the win percentage of the team with two digits after the decimal point and whether the team has a winning or losing average. A team has a winning average if the win percentage is 0.5 or greater. Ex: If the input is Ravens 13 3, where Ravens is the team's name, 13 is the number of team wins, and 3 is the number of team losses, the output is: Win percentage: 0.81 Congratulations, Team Ravens has a winning average! Ex: If the input is Angels 80 82, the output is: Win percentage: 0.49 Team Angels has a losing average. 200506.2440904.qx3zg/7 LAB ACTIVITY 1 #include <iostream> 2 #include <iomanip> 3 #include "Tean.h" 4 using namespace std; 5 7.23.1: LAB - Winning team (classes) 6 7 float Team::GetWinPercentage(int wins, int losses) 8 return (float) (wins) / (float) (wins + losses); 9} 10 11 12 void Tean: printname() { 13 14 15 16 17 18 19 20 21 22 32 33 34 35 36 23 24 25 26 27 28 29 int main() 30 { 31 38 39 float winPerc = GetWinPercentage(wins, losses); cout << fixed <<setprecision (2); Current file: Team.cpp main.cpp Team.h Team.cpp cout << "Win percentage: "<<< winPerc << endl; if(winPerc>= 0.5) { cout << "Congratulations, Tean " << name <<<" has a winning average!" << endl; }else{ cout << "Tean " << name << " has a losing average." << endl; Team t1; cin >>t1.name >>t1.wins >> ti.losses; t1.printname(); return 0; 0/20 Load default template...