Tags:
view all tags
---+ Repetition, files, and Colors ---++ Learning Objective(s) 1 Reinforce repetition 1 Learn to use for statement 1 Learn to read from a file ---++ Overview of the Program The program is to allow the user to guess colors in a file. The file contains numbers representing colors with 4 per row. The program is to allow the user to guess each color and output the number correct. ---++ Details 1 Your colors are to be red, blue, green, and yellow. 1 You must use constants for the colors and the number of colors per line in the file. 1 Reject any invalid numbers (out of range) 1 Use a for loop for the colors in one row 1 Program should be called *CheckColors* ---++ 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 <br>An example of the data file is:<br> <pre>1 1 1 1 2 2 2 1 1 2 3 4</pre> An example of an acceptable dialogue:<br> <pre> What is the name of file? datafile What is your guess for the next color on this line? 1 You got that one right! What is your guess for the next color on this line? 2 You did not get that one right :(. What is your guess for the next color on this line? 1 You got that one right! What is your guess for the next color on this line? 2 You did not get that one right :(. You got 2 right for that line. What is your guess for the next color on this line? 2 You got that one right! What is your guess for the next color on this line? 2 You got that one right! What is your guess for the next color on this line? 2 You got that one right! What is your guess for the next color on this line? 2 You did not get that one right :(. You got 3 right for that line. What is your guess for the next color on this line? 1 You got that one right! What is your guess for the next color on this line? 2 You got that one right! What is your guess for the next color on this line? 3 You got that one right! What is your guess for the next color on this line? 4 You got that one right! You got 4 right for that line. Overall, you got 9 colors correct. </pre> ---++ 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. [[CSS121S2023Lab4H1][Program design]] 1. [[CSC121S2023Lab4H2][I feel overwhelmed. How should I start?]] 1. [[CSC121S2023Lab4H2a][That was ok, but I am still overwhelmed. What else do you have?]] 1. [[CSC121S2023Lab4H3][Hint for file problems]] 1. [[CSC121S2023Lab4H4][Once the user gets 4 colors right, it seems like row is always guessed correctly no matter what]] 1. [[CSC121S2023Lab4H5][I get too many lines of output]] ---++ 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 input the colors as a string and the code not be case sensitive. 1 Handle the exception of a bad file. 1 Output the number of rows correctly
Edit
|
Attach
|
Watch
|
P
rint version
|
H
istory
:
r6
<
r5
<
r4
<
r3
<
r2
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r5 - 2023-01-26
-
cathybareiss
Home
Site map
Assessment web
BethelAIResources2026 web
CenterForComputing web
ChatGPT web
Intro2AIatBethel web
Main web
Sandbox web
TWiki web
CenterForComputing Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
Edit
Attach
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