Question: A designer is trying to create a new pattern of five stripes using three colors. These colors and their codes are mentioned in the table

A designer is trying to create a new pattern of five stripes using three colors. These colors and their codes are mentioned in the table below.

Color

Character Code

Red

R

Green

G

Blue

B


The designer has to keep in mind that no two adjacent stripes are of the same color. For example, RRGBR is an invalid pattern, but RGBRB is valid.

Write a program that accepts a sequence of five colors as input from the designer to form the pattern. At each selection the designer makes, the program should check if the input is from among the available set of colors. Also, the program should check that adjacent colors are not the same. At the end, the program should display the final stripe pattern created.

Step by Step Solution

3.40 Rating (144 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve this problem youll need to write a program that guides the designer in selecting each stripe color while enforcing the provided constraints H... 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

Document Format (2 attachments)

PDF file Icon

609a8c09043e1_30737.pdf

180 KBs PDF File

Word file Icon

609a8c09043e1_30737.docx

120 KBs Word File

Students Have Also Explored These Related Programming Questions!