Answered step by step
Verified Expert Solution
Question
1 Approved Answer
RED WHITE WHITE RED BLUE BLUE RED WHITE RED RED WHITE BLUE WHITE WHITE RED RED BLUE BLUE WHITE WHITE RED WHITE RED BLUE WHITE
RED WHITE WHITE RED BLUE BLUE RED WHITE RED RED WHITE BLUE WHITE WHITE RED
RED
BLUE BLUE WHITE WHITE RED WHITE RED BLUE WHITE WHITE WHITE BLUE WHITE RED
Call the two static void methods you write from your main class. Call the methods whatever name you would like. 1) Write a static void method that does the following using a nested loop a) Using a loop, read a color (of type String) from a textfile called colors.txt this is provided in the Moodle link. Assume you do not know how many colors are in the file. There will be one color per line and will have possible values of RED, WHITE, or BLUE Use switch syntax to count how many of each color are in the file. When you have run out of colors, output each color and the count of each color. example b) c) d) Red count: 146 Blue count: 133 2) Write a static void method that does the following using a nested loop a) Prompt the user to enter an integer between 5 and 20. If they enter a number outside of that range use a validation loop to keep asking then to input a number in the correct range. b) c) Output a d) made from asterisks (*) using a nested for loop. The longest line should contain the int value the user entered made of asterisks, the shortest line one (1) asterisks For example if the user enters 5 you would see Enter a number between 5 and 20
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started