learn.rybooks.com Bar Chart Scoreboard zyBooks My liber ke My library > CSE 1223: Introduction to Computer Programming in Java home > 11.9: Bar Chart Scoreboard = 19. Bar Chart Scoreboard zyBooks catalog Help/FAQ wa 11.9 Bar Chart Scoreboard For this assignment you will write a Java program that uses arrays to create a simple bar chart scoreboard for a group of players. Create a new project named BarChartScoreboard and create a new Java class in that project named BarChartScoreboard.java in the default package This program will ask the user to enter a number of players, then ask the user for each player's name and score. Once all of the players have been entered, the program will display a bar chart with each of their scores scaled as a percentage of the maximum score entered. See below for details on exactly how this should work - an example transcript of how the program should work is shown below (remember that values entered by the user are shown in BOLD and that the output should end with a new line Enter the number of players: 3 Enter a player name: John Wagner Enter the score for John Wagner: 33 Enter a player name: Karen Berger Enter the score for Karen Berger 55 Enter a player name: Jo Duffy Enter the score for Jo Duffy: 15 Current Scoreboard John Wagner Karen Berger Jo Duffy learn.zybooks.com Bar Chart Scoreboard Books My library > CSE 1223: Introduction to Computer Programming in Java home > 11.9: Bar Chart Scoreboard JO Duffy 119 Bar Chart Scoreboard zyBooks catalog Help/FAQ Wanyue Zhang If the user enters a 0 for the number of players, a goodbye message should be displayed instead: Enter the number of players: 0 No players to display? Goodbye! Storing the input You will need to create two arrays to store the data - one to hold player names and one to hold scores. The arrays will be what is known as parallel arrays - two values with the same index will be linked to each other. For example, given the transcript above, the array holding names would have the values [ "John Wagner", "Karen Berger", "Jo Duffy") and the array holding scores would have the values (33,55, 15) Once you have read the values into the two arrays, you can worry about formatting the output Formatting the output The length of the bar for the player with the highest score must be 50 stars. The length of the bars for the other players is determined by using a proportion of their score to the maximum score: numStars - ( score / maxScore ) . 50 For example, if the highest score is 10 and another player has a score of 8, then the length of the second player's bar will be (8/10) 50- or 40 stars: Enter the number of players: 2 Enter a player name: High Scorer Enter the score for High Scorer: 10 Enter a player name: Low Scorer Enter the score for Low Scorer: 8 Current Scoreboard learn.zybooks.com Bar Chart Scoreboard ke My library > CSE 1223: Introduction to Computer Programming in Java home > 11.9: Bar Chart Scoreboard 11.9. Bar Chart Scoreboard Current Scoreboard zyBooks catalog Help/FAQ Wanyue High Scorer ******* Low Scorer NOTE: Remember that if you want to use fractions in Java you have to do some extra work. You can look back at how you computed the percentage in the guess a number project for one way to solve this. Another way to solve it is to recognize that the above equation can be rewritten using a little bit of algebra as: numStars - ( score * 50 ) / maxScore If you do that, you don't have to convert values from int to double and back at all. In general in Java if you don't have to convert between int and double types it is better not to NOTE 2: Notice that the bars all line up on the left hand side, with a single space after the longest name that the user entered. There are a number of ways to solve this problem - one way to do it is to use a loop to append spaces to the end of the shorter names to 'pad them out to the right length. An algorithm to do this might be 1. Determine the string with the longest length, call it max. 2. Start with a variable pos - 0. 3. With the name stored at index pos, loop to append spaces until its length is the same as the length of max. 4. Increment pos by 1. 5. Repeat steps 3 and 4 until all of the strings are the same length NOTE 3: Your solution must be able to handle names of length O and scores of O. You can assume that values entered by the user for scores will be non-negative. In the case of scores of o, no stars should be printed-be careful of division by zero errors when determining your proportions in the case of names of length 0, no name will be printed but the bar may be An example where the player name is left blank would be: Enter the number of players: 1 Enter a player name: Enter the score for 10 11.9. Bar Chart Scoreboard Booke My library > CSE 1223: Introduction to Computer Programming in Java home > 11.9: Bar Chart Scoreboard E zyBooks catalog Help/FAQ 1. Veteriture the string with the longestrengut, can max. 2. Start with a variable pos - 0. 3. With the name stored at index pos, loop to append spaces until its length is the same as the length of max. 4. Increment pos by 1. 5. Repeat steps 3 and 4 until all of the strings are the same length. NOTE 3: Your solution must be able to handle names of length 0 and scores of O. You can assume that values entered by the user for scores will be non-negative. In the case of scores of 0, no stars should be printed-be careful of division by zero errors when determining your proportions! In the case of names of length 0, no name will be printed but the bar may be. An example where the player name is left blank would be: Enter the number of players: 1 Enter a player name: Enter the score for : 10 Current Scoreboard And an example where the player score is set to 0 (and the max score is also zero). Enter the number of players: 1 Enter a player name: Jo Duffy Enter the score for Jo Duffy: 0 Current Scoreboard Jo Duffy ACTIVITY 11.9.1: Bar Chart Scoreboard 0/15