Explore BrainMass

Explore BrainMass

    Java program to memorize a sequence of colors

    Not what you're looking for? Search our solutions OR ask your own Custom question.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Write a program that tests the user's ability to memorize a sequence of colors. As shown in the sample session, the program starts off by displaying a dialog box with a list of colors that are to be memorized - red, white, yellow, green, and blue. The user then enters the colors one at a time in a text box. If the user makes a mistake, the program prints a "Sorry" message. If the user correctly enters all the colors, the program prints a "Congratulations" message. Note that when the sorry or congratulations message is printed, the window's original components get cleared away.

    © BrainMass Inc. brainmass.com December 24, 2021, 8:32 pm ad1c9bdddf


    Solution Preview

    Please find below the java code. The list of colors are stored in the colors string array. Variable guessNumber keeps track of guess attempts made starting from 0 (it is easier to access color array items since they start from ...

    Solution Summary

    A java program in a single java file. When launched you will see a question "How good is your memory? Try to memorize following color sequence: [color list]". Then the form will appear where the user can enter his guess. If the user correctly enters all the colors, the program prints a "Congratulations" message. Solution is provided in two versions using JApplet or JFrame. Choose whichever required.