Advertisement
Leigh47

Programming! [code][/code]

Oct 1st, 2014
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.62 KB | None | 0 0
  1. Your mission: Write a program to determine statistics for a video game tournament. The user will input names and scores of all tournament players. The program will calculate the average score and display the players who scored below average.
  2.  
  3. The program will implement these functions:
  4. Main(): Declares variables for the number of players and average score, and two arrays of size 100: one to store player names and the other to store their respective scores. Calls the following functions in sequence, passing necessary parameters by reference:
  5. InputData( ): Gets player names and scores from the user and stores them into the two arrays for an unknown number of players up to 100.
  6. DisplayPlayerData(): Displays each player's name and score.
  7. CalculateAverageScore( ): Calculates the average score and returns it by value.
  8. DisplayBelowAverage( ): Displays the names and scores of players who scored below average.
  9. Sample output:
  10.  
  11. Enter Player Name (Q to quit): Bob
  12.  
  13. Enter score for Bob: 3245
  14.  
  15. Enter Player Name (Q to quit): Sue
  16.  
  17. Enter score for Sue: 1098
  18.  
  19. Enter Player Name (Q to quit): Dave
  20.  
  21. Enter score for Dave: 8219
  22.  
  23. Enter Player Name (Q to quit): Pat
  24.  
  25. Enter score for Pat: 3217
  26.  
  27. Enter Player Name (Q to quit): Q
  28.  
  29. Name    Score
  30. Bob     3245
  31. Sue     1098
  32. Dave    8219
  33. Pat     3217
  34. Average Score: 3944.75
  35. Players who scored below average
  36.  
  37. Name    Score
  38. Bob     3245
  39. Sue     1098
  40. Pat     3217
  41. Press any key to continue . . .
  42.  
  43. Main Function
  44. Declare player and score arrays, and variables for number of players and average score.
  45. Call the InputData( ) function, passing arrays and number of players variable by reference
  46. Call the DisplayPlayerData( ) function, passing arrays and number of players variable by reference
  47. Call the CalculateAverageScore( ) function, passing arrays and number of players by reference. Store returned value in average variable.
  48. Display the average score
  49. Call the DisplayBelowAverage( ) function, passing arrays and number of players variable by reference, passing average variable by value
  50.  
  51. InputData function
  52. Loop while the number of players is less than the length of the array
  53. Prompt for the player's name
  54. If the user entered Q, break out of the loop
  55. Prompt the user for the player's score
  56. Add 1 to the number of players
  57.  
  58. DisplayPlayerData function
  59. Loop to display the name and score of each player
  60.  
  61. CalculateAverageScore function
  62. Loop to add up the scores
  63. Divide by the number of players to calculate the average score
  64. Return the average score to main
  65.  
  66. DisplayBelowAverage function
  67. Loop to display the names and scores of all players who scored below the average score
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement