Programming Exercises chap4 - Programming Exercises Chapter...

This preview shows page 1 out of 6 pages.

Programming Exercises Chapter 4 5. Color Mixer The colors red, blue, and yellow are known as the primary colors because they cannot be made by mixing other colors. When you mix two primary colors, you get a secondary color, as shown here: ● When you mix red and blue, you get purple. ● When you mix red and yellow, you get orange. ● When you mix blue and yellow, you get green. Design a program that prompts the user to enter the names of two primary colors to mix. If the user enters anything other than “red,” “blue,” or “yellow,” the program should display an error message. Otherwise, the program should display the name of the secondary color that results. Module main ( ) // Declare variable to hold color Declare String color1, color2 //Prompt user to enter two primary colors Call user_input (color1, color2) // Determine the secondary color Call color_mixture (color1, color2) End Module // Get the user input Module user_input (String Ref hue1, String hue2) Display “Enter the name of the first color to mix.” Input hue1 Display “Enter the name of the second color to mix.” Input hue2
Image of page 1
You've reached the end of this preview.
  • Spring '12
  • Carter

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern