Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ language. Working on this assignment and I am getting stuck after the user enters in a menu choice. Trying to make my functions but

C++ language. Working on this assignment and I am getting stuck after the user enters in a menu choice. Trying to make my functions but I am having trouble with the functions after the getTeam() function. Any advice or examples will be appreciated. This is what I have thus far:

#include

#include

#include

using namespace std;

struct WinLoss { int wins, losses; };

struct Team { string teamName; WinLoss home; WinLoss away; WinLoss total; };

int menu();

WinLoss getWinLoss(string location); // This function is good.

void displayWinLoss(WinLoss); //Having trouble with this function

Team getTeam(); // This function is good

void displayTeam(Team); //having trouble getting started on this

void findTeam(Team[], int); // having trouble getting this

int main(){

Team name[20];

int choice; choice = menu();

while (choice != 4) {

if (choice == 1) { getTeam(); }

if (choice == 2) { void displayTeam(Team); }

if (choice == 3) { void findTeam(Team[], int); }

else if (choice < 1 || choice > 4) { cout << "Invalid menu choice! Try again." << endl; cin >> choice; } }

system("pause"); return 0; }

int menu() { int choice; cout << "1. Enter in a new team" << endl; cout << "2. Display all teams" << endl; cout << "3. Display a particular team" << endl; cout << "4. Exit the program" << endl; cin >> choice; return choice; }

WinLoss getWinLoss(string location) { WinLoss record; cout << "Enter in the amount of " record.wins; cout << "Enter in the amount of " record.losses; return record; }

Team getTeam() { Team team; cout << "Enter in a team name: "; cin.ignore(); getline(cin, team.teamName); team.home= getWinLoss("home"); team.away= getWinLoss("away"); return team; }

void displayWinLoss(WinLoss ) { Team totalWins, totalLosses; totalWins.total = totalWins.home.wins + totalWins.away.wins ; totalLosses.total = totalLosses.home.losses + totalLosses.away.losses; cout << "Total Record " << totalWins.total << "-" << totalLosses.total << endl; cout << totalWins.home.wins << "-"<< totalLosses.home.losses << endl; }

void displayTeam(Team) { }

void findTeam(Team[], int) {

string teamName; cout << "Enter in a Team "; cin >> teamName;

}

CIS 1202 Programming Assignment #6 Structured Data 1 A sports team plays games at home and away. Write a program to keep track of a team's win/loss record at home, away, and their total. Use nested structures as you develop this program. Requirements 1. Data structures: a. Define a WinLoss structure with wins and losses members (int). b. Define a Team structure with the team name, containing a WinLoss structure variable for total wins/losses, a WinLoss structure variable for home wins/losses, and a WinLoss structure variable for away wins/losses. c. Declare an array of type Team. 2. Build a menu-driven program with these options: a. Enter a new team b. Display all teams c. Display a particular team d. Exit the program 3. Define these functions according to these prototypes: a. int menu(); Shows the menu Gets the user selection Validates the menu selection Returns a valid menu selection b. WinLoss getWinLoss(string); Gets wins and losses from the keyboard for the location indicated by the string parameter ("home" or "away") and returns a WinLoss structure containing the input. c. void displayWinLoss(WinLoss); Displays a string containing the win and loss members in the format of "wins-losses". d. Team getTeam(); Inputs the team name Inputs home wins and losses using getWinLoss() Inputs away wins and losses using getWinLoss() Stores the home wins/losses in the appropriate team structure Stores the away wins/losses in the appropriate team structure Calculates the total wins/losses and stores those in the appropriate structure Returns all of this in a single Team structure e. void displayTeam(Team); Displays the team name, total wins and losses, home wins and losses, and away wins and losses. Use the displayWinLoss function described above. f. void findTeam(Team[], int); Prompt the user for the team name Search the array for a match If there is a match, display the team information using the displayTeam function described above. If there is no match, display an error message. 4. Functions must pass parameters and return values as needed, using only local variables. Global variables are not allowed. 5. Create any other functions or variables as you see fit.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

1. Calculate the current and quick ratio

Answered: 1 week ago