Anda di halaman 1dari 8

*******************************

*
DESCRIPTION
*
*******************************
A C# application that allows a bowler to enter five
bowling scores, then proceed on doing the necessary
calculations in order to display the average, high and
low scores of the bowler, the C# application also prompts
the bowler to re-run the program if the bowler wishes to.
*******************************
* STEP-BY-STEP PLANNING
*
*******************************
Step One: (Output)
display the bowling scores in putted by the bowler
as well as the average, high and low bowling scores.
Step Two: (Input)
Prompt the bowler to input five bowling game scores, the entry
must be numeric and in a range of 0 to 300 inclusive.
Step Three: (Process)
Repeat this:
Repeat this:
Prompt the bowler to input five bowling game scores, the
entry
must be numeric and in a range of 0 to 300 inclusive.
Using Int.TryParse()method verify if each bowling game
score is an integer.
if the bowler inputs a non-numeric value then display an
entry error
and re-prompt the user to enter again the bowling game s
core.
if the bowler inputs a game score outside the establishe
d
range then display an range error message and re-prompt
the
bowler to enter again the game score.
Once it's confirmed that the entries are integer, then
proceed to verify if the bowling game score is within
the range of 0 to 300 inclusive.
once all five bowling game score passes all the necessar
y
validation then store the bowling game scores into an ar
ray,
the array must be large enough to hold the five values a
nd it

must be declared as an integer.


Repeat until all five bowling game score have been saved correct
ly.
clear the screen of the C# application using console.clear() met
hod
display an output message "Bowler Scores"
display an underline "=================="
Repeat this:
display one-by-one the array that holds the bowling scor
es
repeat until the loop iterates up to the length of the array.
Repeat this:
if "bowlingScores" (integer array variable) is greater t
han "highBowlingScore"
(variable that will be declared as an integer and with a
default
value of zero) then:
save the "bowlingScores" value into "highBowling
Score"
if "bowlingScores" is less than "lowBowlingScore"(variab
le that will be
declared as an integer and with a default value of 500)
then:
save the "bowlingScores" value into "lowBowlingS
core"
Sum the average bowling score by declaring an accumulato
r,
variable type integer that would add up all the values o
f the array into the
accumulator.
repeat until the loop iterates up to the length of the array.
display an underline "=================="
calculate the average bowling score by dividing the accumulator
variable
by the length of the bowlingScores array.
display the average bowling score
display the high bowling score
display the low bowling score
repeat this:

display a message " would you like to process another se


t of
bowler scores?"
Prompt the user "Please enter "Y" to continue or "N" to
exit: "
save the value into a string variable "continueTheProgra
m"(variable
that will be declared as a string and will hold the answ
er of the bowler)
convert "continueTheProgram" value to an upper case
if "continueTheProgram" == "affirmativeAnswer"(variable
that will be
declared as a constant string holding the character "Y")
. then:
re-start the program and await for new bowling g
ames scores for
further calculations.
else if "continueTheProgram" == "NegativeAnswer"(variabl
e that will be
declared as a constant string holding the character "N")
. then:
step out of the loop and close the C# applicatio
n without
displaying any message or further instructions.
else
re-display a message " would you like to process
another set of
bowler sc
ores?"
re-prompt the user "Please enter "Y" to continue
or "N" to exit:
repeat until the user enters "Y" or "N" for an answer
clear the screen using console.clear()
repeat until the user enters "N" for an answer (in other words keep this loop tr
ue)
*************************
*
PSEUDOCODE
*
*************************
*****************
* CONSTANTS
*
*****************

declare SCORE_INPUT_LIMIT as integer with a default value 5 //Integer variable


that will be used a
//default value of
the array of bowling scores
//if the bowler wan
ts to continue or not.
declare NEGATIVE_ANSWER as string with a default value "N"
that will be used to evaluate

//string variable
//if the bowler wa

nts to continue or not.


declare AFFIRMATIVE_ANSWER as string with a default value "Y" //string variable
that will be used to evaluate
//if the bowler w
ants to continue or not.
declare MINIMUN_BOWLING_SCORE as integer with a default value 0 //integer varia
ble that will be used to determine
//if each bowli
ng scores in the array is greater or
//equal to the
minimum range
declare MAXIMUM_BOWLING_SCORE as integer with a default value 300 //integer var
iable that will be used to determine
//if each bow
ling scores in the array is less than or
//equal to th
e maximum range
*****************
* VARIABLES
*
*****************
declare keepRunning as boolean //boolean variable that it is used to keep the C
# application running
//it will always be true UNTIL the bowler does n
ot want to continue with
//the C# application.
declare bowlingScores as an integer array with a size of SCORE_INPUT_LIMIT //int
eger variable array that will be used to hold all the
//bow
ling game scores that the bowler will enter.
declare scoreInput as an integer
the bowling game score

//integer variable that will temporarily hold


//of the bowler so it can pass through all th

e validation, if it passes
//all the validations then the score will sav
ed in the array, else the application
//will ask the bowler to enter again the scor
e.
declare scoreIterator as an integer with a default value 1 //integer variable t
hat will used as an iterator

//to input 5 bowling


game scores of the bowler
declare highBowlingScore as an integer with a default value of MINIMUM_BOWLING_S
CORE
//integer variable that will be used to determine
//the high bowling score of the bowler, it has the value of
//MINIMUM_BOWLING_SCORE this way it will calculate the high score correctly
declare lowBowlingScore as an integer with a default value of MAXIMUM_BOWLING_SC
ORE //integer variable that will be used to determine
//the high bowling score of the bowler, it has the value of
//MAXIMUM_BOWLING_SCORE this way it will calculate the high score correctly
declare averageBowlingScore as double with a default value 0
le that will be used to determine

//integer variab
//the average bo

wling score of the bowler.


declare continueTheProgram as string //string variable that will be used to pro
mpt
//the bowler to enter "Y" or "N" to re-run
the application.
********************************
*
OUTPUT AND PROCESSING
*
********************************
While "keepRunning" variable is true
while scoreIterator is <= BOWLING_SCORE_LIMIT
prompt the bowler "Please enter score for Game " + scoreIterator
+ ": "
if (Int.TryParse(console.ReadLine(), out bowlerScoreInput)
if scoreInput is >= MINIMUM_BOWLING_SCORE AND scoreInput
is <= MAXIMUM_BOWLING_SCORE
bowlingScores[scoreIterator-1] <-- scoreInput
scoreIterator++
else
display range error message "Range Error, bowlin
g score must be within the range {0} - {1} inclusive
Please try again.", MINIMUM_BOWLING_SCORE, MAXIM
UM_BOWLING_SCORE)
else
display entry error message "Entry Error, bowling score
must be numeric. Whole number only. No decimals...

Please try again."


loop until "scoreIterator" variable is > than "BOWLING_SCORE_LIMIT"
clear the console screen using console.clear()
display a message "Bowler Scores"
display "========================="
for(integer displayScores <-- 1 ; displayScores is <= SCORE_INPUT_LIMIT
; displayScores++)
display "game {0} : " + bowlingScores[displayScores-1] + " ", display
Scores
loop the for until "displayScores" variable is > than "SCORE_INPUT_LIMIT
"
for(integer categorizeScores <-- 1 ; categorizeScores <= SCORE_INPUT_LIM
IT ; categorizeScores++)
if bowlingScores[categorizeScores-1] is >= highBowlingScore t
hen:
highBowlingScore <-- bowlingScores[categorizeSco
res-1]
if bowlingScores[categorizeScores-1] is <= lowBowlingScore) t
hen:
lowBowlingScore <-- bowlingScores[categorizeScor
es-1]
averageBowlingScore + <-- bowlingScores[categorizeScores-1]
loop the for until "categorizeScores" variable is > than "SCORE_INPUT_LIMIT"
display "==============================="
averageBowlingScore /= bowlingScores.Length
display "Average Score for Bowler: {0:n0} ",averageBowlingScore
display "High Score for Bowler: {0} ", highBowlingScore
display "Low Score for bowler: {0} ", lowBowlingScore

do this
display a message " would you like to process another set of bow
ler scores?"
prompt the user "Please enter "Y" to continue or "N" to exit: "
convert the variable "continueTheProgram" to an upper case using
.ToUpper()
continueTheProgram <-- console.ReadLine().ToUpper()
if continueTheProgram is == AFFIRMATIVE_ANSWER
scoreIterator <-- 1
else if continueTheProgram is == NEGATIVE_ANSWER
keepRunning <-- False
while "continueTheProgram" is != "AFFIRMATIVE_ANSWER" AND "continueThePr
ogram" is != "NEGATIVE_ANSWER"
clear the screen using console.clear()
loop until "keepRunning" variable is false.
*****************
* DESKCHECK
*
*****************
Input:
Output:
---------------------------------------------------------------------45
67
250
300
265

Average Score: 185


High Score: 300
Low Score: 265

---------------------------------------------------------------------600
Gandalf

Range error scores must be


within 0 - 300 inclusive.
Entry Error scores must be
numeric, whole numbers, no

decimals.
300
200
147
209
439

Range error scores must be


within 0 - 300 inclusive.
Average score: 252
High Score: 300
Low Score: 147

219
----------------------------------------------------------------------

Anda mungkin juga menyukai