Question

Create a statistics program in C++ for sports (which ever sport you'd prefer). The program must...

Create a statistics program in C++ for sports (which ever sport you'd prefer).

The program must use at least one menu at the beginning with multiple options including an option to exit the program.
The program must run continuously, in a cyclic manner until the user chooses to exit.
Sublevel menus are allowed.
The program must use: multiple data types, multiple mathematical operators, decision structures, iterative structures, and functions.
The program should be thoroughly documented with introductory comments at the top and other comments in areas that could be confusing.
The program should be easily readable and use proper indention.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>

using namespace std;

int main() {

//Delcaring Variable Option_Input to take input from user

int Option_Input=1;

//Boolean variable to exit while loop

int exit=0;

//variable to take name of players

char FirstPlayerName[30];

char SecondPlayerName[30];

//variable to take number of games

int NumberOfGames;

int count = 0;

//player one results

int PlayerOneResults;

int PlayerOneTotal=0;

//player 2 results

int PlayerTwoResults;

int PlayerTwoTotal=0;

//Diplaying Welcome messgae

cout << "Welcome to Tennis game\n";

cout<<"---------------------------";

//While to rerun program untill user choose to exit

while(Option_Input==1){

cout<<"\nPlease select option :\n1.Start Game\n2.Quit --->";

//User input will be stored in Option_Input

cin>>Option_Input;

//if user select opton 2 then program will get end

if(Option_Input==2){

break;

}

//if user choose option 1 below items will occur

else if(Option_Input==1){

/*Taking 1st player name and 2nd player names*/

cout<<"\tMaximum number players is two.\n\t---------------------------\n\tPlease enter name of 1st Player: ";

cin>>FirstPlayerName;

cout<<"\tPlease enter name of 2nd Player: ";

cin>>SecondPlayerName;

/* Below are some rules related to game*/

cout<<"\n\n\t\t Below are values need to enter to identify winner of game.\n\t\t1.Represents winner\n\t\t2.Represents Loser.\n\t\t(Note: If you enter 1 or 0 for both players then its a draw.)\n\n";

cout<<"\t\t\tPlease enter how many number of games you want play:";

cin>>NumberOfGames;

//for loop to take values of each player based on NumberOfGames

for(int i=1;i<=NumberOfGames;i++){

cout<<"\t\t\t"<<i<<" Game. Enter 1 if "<<FirstPlayerName<<" wins.Else enter 0 : ";

cin>>PlayerOneResults;

//calculating total number of wins by 1st player

PlayerOneTotal=PlayerOneTotal+PlayerOneResults;

cout<<"\t\t\t"<<i<<" Game. Enter 1 if "<<SecondPlayerName<<" wins.Else enter 0 : ";

cin>>PlayerTwoResults;

//calculating total number of wins by 2nd player

PlayerTwoTotal=PlayerTwoTotal+PlayerTwoResults;

}

cout<<"\n\n\n___________________________\n";

//Displaying output based on score of players

if(PlayerOneTotal>PlayerTwoTotal){

cout<<FirstPlayerName<<" wins.";

}

else if(PlayerOneTotal<PlayerTwoTotal){

cout<<SecondPlayerName<<" wins.";

}

else{

cout<<"It's a draw.";

}

}

else if(Option_Input==2){

exit=1;

}

cout<<"\n___________________________\n";

}

}



















main.cpp B saved gcc version 4.6.3 int PlayerOneTotal-e int PlayerTwoResults; int PlayerTwoTotal-e; //Diplaying Welcome messgae cout << Welcome to Tennis game\n; 12 13 Welcome to Tennis game Please select option 1.start Game 2.uit 7 15 17 18 while(option-input-1)( 19 2 /User input will be stored in Option Input 21 cout<<nPlease select option \n1.Start Game\n2.Quit cin>>option Input; 22 if(option_Input--2) 23 24 break; 25 else if(option_Input--1) cout<< tMaximum number players is two.\n\tーーーーーーーーーーーーーーー\n\tPlease enter name of 1st Player : cin>>FirstPlayerName; cout<<\tPlease enter name of 2nd Player cin>>SecondPlayerName; cout<<ninitit Below are values need to enter to identify winner of game.\nltlti.Represents inner nltit2.Represents Loser.nitlt(Note: If you enter 1 or e for both players then its a draw.)Inin cout<<\tltitPlease enter how many number of games you want play: cin>>NumberOfGames; for(int i-1;i<«NumberofGames:1++){ 27 29 38 31 32 cout<<\t\t\tくくicc Gane . Enter 1 if ..<<FirstPlayerName<< enter e: ; cin>>PlayerOneResults; PlayerOneTotal-PlayerOneTotal+PlayerOneResults; 34 wins . Else 35 36

Add a comment
Know the answer?
Add Answer to:
Create a statistics program in C++ for sports (which ever sport you'd prefer). The program must...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C LANGUAGE. PLEASE INCLUDE COMMENTS :) >>>>TheCafe V2.c<<<< #include ...

    C LANGUAGE. PLEASE INCLUDE COMMENTS :) >>>>TheCafe V2.c<<<< #include <stdio.h> int main() { int fries; // A flag denoting whether they want fries or not. char bacon; // A character for storing their bacon preference. double cost = 0.0; // The total cost of their meal, initialized to start at 0.0 int choice; // A variable new to version 2, choice is an int that will store the // user's menu choice. It will also serve as our loop control...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT