7.23 LAB - Winning team (classes) Given main(), define the Team class (in files Team.h and Team.cpp). For class member f

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
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

Post by answerhappygod »

7 23 Lab Winning Team Classes Given Main Define The Team Class In Files Team H And Team Cpp For Class Member F 1
7 23 Lab Winning Team Classes Given Main Define The Team Class In Files Team H And Team Cpp For Class Member F 1 (56.88 KiB) Viewed 85 times
7 23 Lab Winning Team Classes Given Main Define The Team Class In Files Team H And Team Cpp For Class Member F 2
7 23 Lab Winning Team Classes Given Main Define The Team Class In Files Team H And Team Cpp For Class Member F 2 (58.63 KiB) Viewed 85 times
7 23 Lab Winning Team Classes Given Main Define The Team Class In Files Team H And Team Cpp For Class Member F 3
7 23 Lab Winning Team Classes Given Main Define The Team Class In Files Team H And Team Cpp For Class Member F 3 (69.37 KiB) Viewed 85 times
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.qx3zg/7 LAB ACTIVITY File is marked as read only 1 #include <iostream> 2 #include <string> 3 #include "Tean.h" 4 using namespace std; 5 6 int main() { 7 8 9 10 11 12 13 14 15 16 7.23.1: LAB - Winning team (classes) 17 18 19 20 21 22 23 string name: int wins; int losses; Team team; cin >> name: cin >> wins: cin >> losses; team. SetName(name); team.SetWins (wins); team.SetLosses (losses); team.PrintStanding(); return 0; Current file: main.cpp - 0/20
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...
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply