labA1_pseudo_code - ISAT 252 Spring 2012

advertisement
ISAT 252 Spring 2012
Lab A1
Dr. Salib
ISAT 252 – Programming & Problem Solving
Lab A1: Planning Your Program
Algorithms
Due Date: February 3 before class
Objectives:




Utilize the Program Development Process described in class in the development of a
simple application.
Exercise the use of flowcharts and pseudo-code in describing the algorithm(s) and
designing a simple application.
Develop a set of use or test cases (sunny day scenarios and rainy day scenarios)
Implement the application/solution using Python 2.x, test and debug your code.
Deliverables:
(Per team) – To be posted on BB
1. An e-copy of the flowchart, pseudo-code and test cases for the Guess_My_Number
application definition (one for version 1 and another for version 2)
2. An e-copy of the Guess My Number Python program (Guess_My_Number_ver1.py &
Guess_My_Number_ver2.py)
Instructions:
Develop a Guess My Number program
First version
The program you’ll create in this lab is the classic number guessing game. The game goes like
this: the program chooses a random number between 1 and 100 and the player tries to guess it
in as few attempts as possible. Each time the player enters a guess, the program tells the player
whether the guess is too high, too low, or right on the money. Once the player guesses the
number, the program prints the number of attempts made by the player to guess the right
answer.
Make sure the program will allow the values 1 and 100. Make sure that you write in a contingent
plan for if someone enters a value not within the range. Don’t let it crash, have it tell them to
guess again and remind them that it is 1-100.
Second version
Modify the Guess My Number program so that the player has only five guesses. If the player runs
out of guesses, the program should end the game and display an appropriately chastising
message.
the program should randomly select a number.
Do not reveal the number to the user
Prompt the user to enter a number n=1-100
This is the users guess.
The program should compare the user input to the randomly selected number, number defined.
If the user input is equal to the defined random number then print ‘correct! (N)’
If the user input does not equal the defined random number, print ‘incorrect! Try again’
1|P age
ISAT 252 Spring 2012
Lab A1
Dr. Salib
Allow another user input.
2 Program prints ‘welcome to my game. Guess my number?”
the program should randomly select a number.
The random number generated should exist within the set [1,2,3…100]
The randomized number will = the random number definition.
Do not reveal the number to the user
Prompt the user to enter a number n=1-100
This is the user input.
The program should compare the user input to the random number definition, number defined.
If the user input exists outside the set, print ‘Unacceptable value’ print ‘Remember to choose a
number in the set [1,2,3…100]’
If the user input is equal to the defined random number then print ‘correct! (n)’
If the user input does not equal the defined random number, print ‘incorrect! Try again’
Allow another user input.
3 Program prints ‘welcome to my game. Guess my number?”
the program should randomly select a number.
The random number generated should exist within the set [1,2,3…100]
The randomized number will = the random number definition.
Do not reveal the number to the user
Prompt the user to enter a number n=1-100
This is the user input.
The program should compare the user input to the random number definition, number defined.
If the user input exists outside the set, print ‘Unacceptable value’ print ‘Remember to choose a
number in the set [1,2,3…100]’
If the user input is equal to the defined random number then print ‘correct! (n)’
If the user input does not equal the defined random number, print ‘incorrect! Try again’
Allow another user input.
Program prints ‘welcome to my game. Guess my number?”
Print ‘User you have 5 guesses to correctly guess my number’
Print ‘My number is a value 1 through 100, including values 1 and 100.’
Print ‘Input your guess and I will tell you if you are correct’
the program should randomly select a number.
The random number generated should exist within the set [1,2,3…100]
The randomized number will = the random number definition.
Do not reveal the number to the user
Prompt the user to enter a number n=1-100
This is the user input.
The program should compare the user input to the random number definition, number defined.
If the user input exists outside the set, print ‘Unacceptable value’ print ‘Remember to choose a
number in the set [1,2,3…100]’
If the user input is equal to the defined random number then print ‘correct! (n)’
If the user input does not equal the defined random number, print ‘incorrect!
The program should compare the user input to the random number definition and determine
whether the user input is higher or lower than the random definition.
Print either ‘Your guess is too high’ or ‘Your guess is too low’
Allow another user input up to 5 iterations.
2|P age
Download