Difference: CSC121S2023Lab04 (1 vs. 2)

Revision 22023-01-10 - cathybareiss

Line: 1 to 1
 
META TOPICPARENT name="CSC121SylS2023"

Repetition, files, and Colors

Learning Objective(s)

Line: 73 to 73
 
  1. Program design
  2. I feel overwhelmed. How should I start?
  3. Hint for file problems
Changed:
<
<
  1. Once the user gets 4 colors right, the row is always guessed correctly
>
>
  1. Once the user gets 4 colors right, it seems like row is always guessed correctly no matter what
 
  1. 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.

Revision 12023-01-10 - cathybareiss

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="CSC121SylS2023"

Repetition, files, and Colors

Learning Objective(s)

  1. Reinforce repetition
  2. Learn to use for statement
  3. 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 read, blue, green, and yellow.
  2. You must use constants for the colors and the number of colors per line in the file.
  3. Reject any invalid numbers (out of range)
  4. Use a for loop to the colors in one row
  5. 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
An example of the data file is:
1 1 1 1
2 2 2 1
1 2 3 4
An example of an acceptable dialogue:
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.

Submission

  1. create an empty zip folder
  2. place your java file into it
  3. create a pdf document that contains your Software Development Report for this program and place the pdf file into the zip folder
  4. submit the zip folder on canvas

Hints

  1. Program design
  2. I feel overwhelmed. How should I start?
  3. Hint for file problems
  4. Once the user gets 4 colors right, the row is always guessed correctly
  5. 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.
  2. Handle the exception of a bad file.
  3. Output the number of rows correctly
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 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