Question: Write a program that fills a String array with red and green balls. The length of array and order of the balls in the

Write a program that fills a String array with red and green 

Write a program that fills a String array with red and green balls. The length of array and order of the balls in the array is decided by the user. The user enters "R" for red colored balls and "G" for green colored balls. If the user enters more than specified number of balls (let's say N), the program shall read only first N balls and ignore the extra ones. After filling the array, program shall print it to the screen. Part B, 40 Points: After filling the array, your program shall look for all green balls surrounded by red colored balls on both sides and re-color such balls as blue, indicated by letter "B". After re-coloring, the program shall print all the balls again. //Sample Output Enter the required size of ball-array 10 Enter 10 balls, randomly colored red and green. Write R for red, and G for green colored ball RGRRRGGRGR Original Array: RGRRRGGRGR Updated Array: R BRRRGGRBR

Step by Step Solution

3.41 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Algorithm to achieve the described functionality Prompt the user for the size of the ball array Prompt the user to enter the colors of the balls Read ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!