Saturday, January 18, 2020
Programming – Example of a Selection Structure
Introduction:The purpose of this paper is to provide a simple example of a selection structure that is contained as part of the Programming Solution Proposal I am developing throughout the course of this programming class. The selection structure I chose to make an example of isnââ¬â¢t really inclusive as part of my original programming proposal due in week 5, however, I devised a very simple ââ¬Å"If-Then-Elseâ⬠structure that uses somewhat of the same information and calculation as what I may use in my final proposal. Iââ¬â¢ve written the pseudocode for a section that at this time appears to make sense to use, given the selection structure I chose, and I also paralleled that with a Visual Logic com/cards/">flowchart. The visual logic flowchart was executed correctly with specific values that are to be used in order for others to properly test it. These values will change as the program gets fine-tuned, however, for now there are specific values that must be used to obta in the correct percentages. Purpose of the structureThe reason I chose the ââ¬Å"If-Then-Elseâ⬠structure is because it seemed to make the most sense for my program and it didnââ¬â¢t appear to be too complicated a structure to master. Even though this structure may not be included as part of my final proposal paper, I thought it would be good to work with and verify if I could somehow make it work. The program Iââ¬â¢ll ultimately be creating is one where seasonal stats will be entered in by an assistant coach, for athletes on any given basketball team.Through this they will be able to determine a players overall field goal average, free throw percentage, rebound average, etc. However, for now, Iââ¬â¢ve decided to simply use an If-Then-Else structure that displays a friendly output message of what the user might see if he/she entered their ââ¬Å"field goals attemptedâ⬠à value and ââ¬Å"field goals madeâ⬠value. The pseudocode for the If-Then-Else structur eAgain, I must reiterate, that the selection structure I chose to use may not be part of my final proposal paper, however, the pseudocode that is displayed below is a simple and short example of how I used the information for my original proposal, using the If-Then-Else structure: Write ââ¬Å"Enter amount of field goals attempted: ââ¬Å"Input FGA Write ââ¬Å"Enter amount of field goals made: â⬠Input FGM Set Average = FGM / FGA If Average => 50 Then Set FieldGoalAverage = Average Write ââ¬Å"Your field goal average is: â⬠+ FieldGoalAverage + ââ¬Å"%â⬠Else Write ââ¬Å"Your field goal average is: â⬠+ FieldGoalAverage + ââ¬Å"%â⬠Write ââ¬Å"You need to work on your shooting game!â⬠End IfVisual Logic flowchart The Visual Logic flowchart I put together, which parallels the pseudocode above, has been executed successfully. The field goal average in this VL example is calculated using the following values: FieldGoalAttempts (FGsAttempted): 5000 FieldGoalsMade (FGsMade): 50 The values for the variables above test the ââ¬ËTrueââ¬â¢ decision statement. Entering the following values below execute and test the ââ¬ËFalseââ¬â¢ decision statement: FieldGoalAttempts (FGsAttempted): 2000FieldGoalsMade (FGsMade): 50 The .vls file has been uploaded as a separate attachment in the Assignments tab of the UoP Student website.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.