Question:
Help with C++ program, please help.?
FutureMaleRN
2010-03-24 15:16:25 UTC
Hello I am working on a program for my C++ class and I need some help here are some of the instructions;

Process one team at a time. Prompt the user for the first team's scores by first asking for player one's score for game one, then game two, and then game three. Edit each bowling score, and do not continue the program until a valid value is entered. A bowling score can be between 0 and 300, inclusive. If an invalid score is entered, print an error message with the invalid score and request a valid score be entered. After player's one scores are correctly entered, calculate the series total by adding his/her games' scores. Calculate the player's game average (2 decimal precision) by dividing series by number of games. Then print that player's individual games' scores, his series, and his game average. Although three is generally recognized as the number of games in a bowling series, use a symbolic constant for number of games. For this program, assign the number three to the symbolic constant for number of games in a series. Code the program in a way that if the number of games ever changed in series, the only change to your program would be a change to the value of the symbolic constant.

1. first how would I set the boundries
2. How would I set up the constant for number of games?
like this: const double numberofgames = 3
or
like this: const int arr[3] = { }


After the first player's processing is complete, start processing the other players' scores on the team. For this program's purpose, use a symbolic constant for the number of players on a team and assign it a value of four. Again, if number of players per team ever changes, the only change to your program should be the value of your symbolic constant.

Again would i set the constant as an array or just a double

Use an array to store the bowling scores. You may need more than one array. You do not need to use a two dimensional array but you can if you want. You must have at least 1 function that accepts an array as an argument and updates the array in the function. You may have more than one function that accepts an array as an argument. Do not use any global variables. Symbolic constants may be used and these may be global.

How would I set up an array that takes numbers, stores them, and then prints them when prompted?

Also in the program one line of code I have reads this:
cout << "enter scores for team " << endl;

i need it to read team 1, team 2, team 3, etc....
how could I get it to keep counting.

I am not asking for you to do all my coding for my just maybe some examples or pointers to guide me in the right direction

btw, I forgot to mention before it is a program that tallys up bowling scores for an infinite number of teams until prompted to stop
Three answers:
Nick T
2010-03-24 15:55:46 UTC
First off, and no disrespect intended; I think may be you need to talk with your instructor as its obvious from your comments that you haven't quite grasped the concepts required. Your instructor is the one best placed to help you, it is actually their job!



You want to define a (symbolic) constant for the number of players on a team and the number of games in a series. Can you have 2.2 games in a series? or 3.4 players ona team? No, so they don't need to be floating point.



const int GAMES_IN_A_SERIES = 3;

const int PLAYERS_PER_TEAM = 4;



You now want to keep score for each game for each player.

Again a bowling score cannot be 34.1 so still no need for floating point data although it does make it simpler when calculating the average later on.



int GameScores[GAMES_IN_A_SERIES];



I've reread the text several times and cannot see anything that requires you to retain the scores after you have processed them. so you dont need more than one set.

To keep track of the team number just use a counter. Increment it each time around the team loop.Then you can use the same counter as a part of the prompt



cout << "enter scores for team " << teamNumber << endl;



you dont mention how you exit the program? I'd suggest entering -1 as a way to exit the loop.



To loop around for each player in a team you would use the PLAYERS_PER_TEAM constant.

To loop around for each game in a series you would use the GAMES_IN_A_SERIES constant.



I'd suggest using a function to validate the scores being entered, but thats a personal choice.

You could also use a function to perform the printing and another for the calculation of the series total and players average
?
2016-04-12 12:21:52 UTC
Not anymore, at one time C++ was just an extension of C. Since then, C has changed, and so has C++. However that being said it's not unusual for the same program to compile both C and C++. The method is the same, but there are just some differences int he libraries that you need the compiler to link to.
El1jahXTM
2010-03-24 15:21:01 UTC
thedownloadswitch.net

thedownloadswitch.net

thedownloadswitch.net

thedownloadswitch.net

thedownloadswitch.net



go there. theyll help u.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...