Question: Write a piece of code that reads a shorthand text description of a color and prints the longer equivalent. Acceptable color names are B for

Write a piece of code that reads a shorthand text description of a color and prints the longer equivalent. Acceptable color names are B for Blue , G for Green , and R for Red . If the user types something other than B , G , or R , the program should print an error message. Make your program case-insensitive so that the user can type an uppercase or lowercase letter. Here are some example executions:

What color do you want? B You have chosen Blue. What color do you want? g You have chosen Green. What color do you want? Bork Unknown color: Bork

What color do you want? B You have chosen Blue. What color do you want? g You have chosen Green. What color do you want? Bork Unknown color: Bork

Step by Step Solution

3.42 Rating (168 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Code to read redgreenblue color Scanner console new Scanner Systemin Systemoutpr... 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 Building Java Programs A Back to Basics Approach Questions!