---+ Selection and Color Matching ---++ Learning Objective(s) 1 Learn to use the *if* statement 1 Learn to use constants 1 Write your first program on your own ---++ Overview of the Program For this program you are to get three colors choices from the user (red, green, blue) and then inform the user if they are all the same or all different. ---++ Details 1 Use constants for numbers to represent each color. The user is to input a number (1-3) to represent a color. 1 Be sure your prompts inform them as to what each number means 1 If the colors are the same, you are to inform the user that they are the same and what color they are. 1 Program should be called *ColorMatcher* ---++ Example program dialogue: These are not meant to be sufficient testing. Nor must you follow the exact wording. They are just to demonstrate what an acceptable program might do for certain input ---+++ Example 1: <pre>What is your first color (1=blue, 2=red, 3=green) 1 What is your next color? 1 What is your third color? 1 They are all blue.</pre> ---+++ Example 2 <pre>What is your first color (1=blue, 2=red, 3=green) 1 What is your next color? 2 What is your third color? 3 The colors are all different</pre> ---+++ Example 3 <pre>What is your first color (1=blue, 2=red, 3=green) 2 What is your next color? 2 What is your third color? 3</pre> ---++ Program design * Necessary code and banner comment * class * declare constants * main method * declare variables * input with prompts * conditional output ---++ Submission a. create an empty zip folder a. place your java file into it a. create a pdf document that contains your Software Development Report for this program and place the pdf file into the zip folder a. submit the zip folder on canvas ---++ Hints 1 [[CSC121S2023Lab2H1][Hint for writing the selection component]] 1 [[CSC121S2023Lab2H2][Hint if your code is starting to get complex]] ---++ Optional improvements Optional improvements should ONLY be worked on once the program is completing working. In addition, the work is to be done on your own with little if any help for lab assistants or the instructor. 1 Allow the user to type in the color as a word. Convert that word to the appropriate number in your code. For more of a challenge, allow the user to use upper or lower case as they wish. 1 Have it also output what color is represent twice when two inputs are the same. 1 Do the original program with only two if statements with at most three boolean expressions in each. You may also use one switch statement 1 Have it reject any bad values
This topic: CenterForComputing
>
WebHome
>
Syllabi
>
CSC121SylS2023
>
CSC121S2023Lab02
Topic revision: r1 - 2022-12-29 - cathybareiss
Copyright © 2008-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback