Write a program that fills a String array with red and green balls. The length of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
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 the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
An algorithm has been written in pseudocode to input some numbers. It only outputs any numbers that are greater than or equal to 100. The number 999 is not output and stops the algorithm. INPUT...
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
A contractor has the opportunity to choose between building a house or doing two extension works in the next 6 months. If you build the house and sell it, you can make $25,000. However, if the...
-
The first moment of the shaded area with respect to the x-axis is denoted by Qx. (a) Express Qx in terms of b, c, and the distance y from the base of the shaded area to the x-axis. (b) For what value...
-
Distinguish between the two-tier and three-tier client-server models. Describe when each would be used.
-
It looks to me that you have devoted everything to this company and they have treated you badly. Is that right?
-
Pastel Bags (PB) is a designer of high-quality backpacks and purses. Each design is made in small batches. Each spring, PB comes out with new designs for the backpack and for the purse. The company...
-
You have calculated the historical dollar weighted return, annual geometric average return and annual arithmetic average return. You always reinvest your dividends and interest earned on the...
-
Consider a no-load mutual fund with $200 million in assets and 10 million shares at the start of the year and with $250 million in assets and 11 million shares at the end of the year. During the year...
-
Joanna is staring work with an annual salary of $40,000. If her salary increases by 5 percent a year, what will her salary be 40 years from now? If prices increase by 3 percent a year, how much...
-
Explain why this statement is incorrect: When two assets have a +1.00 correlation, they move up and down at the same time, with the same magnitude.
-
A 1989 radio commercial claimed If you have a LifeAlert security system, your chances of becoming a victim of a serious crime are 3,000 to 4,000 percent less than your neighbors. Is this possible?
-
Suppose that you have ten observations that have a mean of 7, a median of 6, and a standard deviation of 3. If you add 5 to the value of each observation, what are the new values of the a. Mean? b....
-
Explain how the following two newspaper headlines that appeared on the same day could both be accurate: Orders for Machine Tools Increased 45.5% in October ; October Orders for Machine Tools...
-
After the productive team meeting, Fullsofts chief technology officer (CTO) wants further analysis performed and a high-level plan created to mitigate future risks, threats, and vulnerabilities. As...
-
l ask this second time correnct answer is 38,01 can we look pls Consider a non-conducting rod of length 8.8 m having a uniform charge density 4.5 nC/m. Find the electric potential at P, a...
-
The gcd(m, n) can also be defined recursively as follows: If m % n is 0, gcd(m, n) is n. Otherwise, gcd(m, n) is gcd(n, m % n). Write a recursive method to find the GCD. Write a test program that...
-
A full binary tree is a binary tree with the leaves on the same level. Add a method in the BST class to return true if the tree is a full binary tree. /** Returns true if the tree is a full binary...
-
Write a JSF program that generates addition quizzes randomly, as shown in Figure 33.29a. After the user answers all questions, it displays the result, as shown in Figure 33.29b. Exercise33_05 -...
-
True or False: Engineers seldom have an opportunity to influence the recovery period for expenditures.
-
A lumber company purchases and installs a wood chipper for \(\$ 200,000\). The chipper is classified as MACRS 7-year property. Its useful life is 10 years. The estimated salvage value at the end of...
-
True or False: Straight-line depreciation is the most popular depreciation method used in financial reporting.
Study smarter with the SolutionInn App