Selection Lab Program: Fall 2024

03 Sep 2024 - 17:26 | Version 1 |

Learning Objective(s)

  • Learn to use constants
  • Learn to use selection statements
  • Learn to use random numbers
  • Learn the syntax of compound statements
  • Learn to do statement coverage testing
  • Develop a complete program.

Overview of the Program

The program is to pick a random integer within a specified range. The user is allowed to get a number of hints, then must guess the number. Hints:
  • if it is a multiple of a number specified by the user
  • if it is higher than another number specified by the user
  • if it is lower than a third number specified by the user

Specifics

  • The program is to be called SimpleGuess
  • Must have a constant MAX that specifies the largest number possible.
  • Use a Random object to have the computer pick a number
  • Use at least one compound statement. I suggest two output statements when the user guesses wrong.
    • One to tell the user that they were wrong.
    • One to tell the user what the number was.

Sample dialogue

Below are some sample dialogues. Your output can vary somewhat as long as the required data is nicely displayed.
Dialogue 1:
I have a number between 0 and 50
You will receive 3 hints and then you must 
try to guess it.
I will tell you if it is a multiple of a number.
What number do you want me to use?  5
My number is not a multiple of 5
I will tell you if is higher than a number.
What number do you want me to use? 15
My number is higher than 15
I will tell you if is lower than a number.
What number do you want me to use? 40
My number is lower than 40
It is time to guess my number.
What do you think it is? 34
You did not guess it.
My number was 31
Dialogue 2
I have a number between 0 and 50
You will receive 3 hints and then you must 
try to guess it.
I will tell you if it is a multiple of a number.
What number do you want me to use? 4
My number is a multiple of 4
I will tell you if is higher than a number.
What number do you want me to use? 37
My number is not higher than 37
I will tell you if is lower than a number.
What number do you want me to use? 33
My number is not lower than 33
It is time to guess my number.
What do you think it is? 36
You guessed it!
You can also run a solution for this program if you want. See classroom instructions for more details.

Lab Hints

Submission

  • Create a software development report
    • For the system design, you may use my flowchart if it is the design of your program. Otherwise, you need to make your own.
    • For testing report,
      • make sure your tests ensure that each statement is executed at least one.
      • your expected output CANNOT be pasted from the dialogue of a running. Only the actual output may be pasted
    • For the improvement section, specify how many points were lost from the last lab that you should not lose points for on this lab because you corrected the problem
    • create a pdf document from your software development report
    • create an empty zip folder
    • place only SimpleGuess.java and your pdf document into it
    • submit the zip folder on canvas

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. Compare your first lab to the solution.
    • Explain how they are different. Include
      • Do the differences matter in terms of producing the correct output?
      • Do the differences matter in terms of the style required?
    • Were the any problems with the solution (in terms of correctness, style, etc.)
    • What have your learned from this comparison about your own programming?
    • Create a pdf document with your answers and add it to your zip folder
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback
This website is using cookies. More info. That's Fine