Showing posts with label Algorithm. Show all posts
Showing posts with label Algorithm. Show all posts
Thursday, 11 April 2013
Algorithm 2 & Java: Part 1
Problem description:
Each frame, X is incremented by R and Y is incremented by T. If X becomes greater than 5000 then Y is decremented by 1000. If Y becomes less than 0, Y and X are set to 0.
Inputs
R, T, X, Y
Outputs
X, Y
Processing / pseudocode
get/set X = 1000
get/set Y = 900
prompt user for value of R
prompt user for value of T
X += R
Y += T
get R
get T
If X > 5000
Y = Y - 1000
if Y < 0
Y = 0
X = 0
End if
End if
Original Post Mar 26th 2012
If …Then … Else statements
If …Then … Else statements
The If Then statement tests whether an If condition is true or false - if it is true Then will execute
The If Then Else statements test whether an If condition is true or false – if it is true Then will execute – if it is false Else will execute
These can be used to test input values and match it against multiple conditions to provide an outcome based on whether the value is validated as true or false
The value will be tested against each condition, in order, until it is found true
If none are true Else will execute
Eg. if Y = 1 then print 1
if Y = 2 then print 2
If Y = 3 then print 3
else print fail
Original Post Mar 4th 2012
Activity 4.4 Blog Task: Switch
Create the pseudocode for a switch statement that checks the value of a variable named Color.
The possible values include Pink, Green, Purple, Orange, Black.
The switch statement should display the color. Include an Else Case.
Original Post Feb 27th 2012
Activity 4.3 Blog Task: And
1. Read the following pseudocode:
If Number > 8 And Number < 10
Display “This number meets the condition.”
Else
Display “This number does not meet the condition.”
End If
2. Answer the following question:
What number would need to be stored in Number to make this program display the message “This number does not meet the condition”? Why?
Answer
To get the message “This number does not meet the condition” the user would have to select any number that <=8 and >=10
The pseudocode requires the number 9 to meet the condition
Original Post Feb 27th 2012
Activity 4.2 Blog Task: Or
1. Read the following pseudocode:
If Number > 8 Or Number = 10
Display “This number meets the condition.”
Else
Display “This number does not meet the condition.”
End If
2. Answer the following question:
What number would need to be stored in Number to make this program display the message “This number does not meet the condition”? Why?
Answer
To get the message “This number does not meet the condition” the user would have to select any number that <=8
The pseudocode requires any number greater than 8 to meet the condition
Original Post Feb 27th 2012
Developing Algorithms
The 5 steps used to develop an algorithm
1. Define the problem
2. Define the inputs
3. Define the outputs
4. Define processing
5. Develop the algorithm (pseudocode & flow chart)
Original Post Feb 27th 2012
Individual Activity: Update Environment Variables Part 1
Step 1 : Define Problem
Each frame, X is incremented by R and Y is incremented by T. If X becomes greater than 5000 then Y is decremented by 1000. If Y becomes less than 0, Y and X are set to 0.
Original Post Feb 26th 2012
Group Activity 1
I made some fundamental errors in this process
1. I assumed the algorithm would be an endless loop because of the previous task, The Never Ending Algorithm
2. I worked backwards by designing the flowchart before working on the pseudocode
Original Post Feb 24th 2012
Blog Task: Activity 3.2
1. Describe how the algorithms you developed in 1.1 and 1.2 end.
My previous algorithms, (1.1 and 1.2), both have an end
In both cases the algorithms have a stop when the task is properly completed and the result displayed, or, when the user fails 5 times to provide correct data a fail message is displayed and the algorithm stops.
Original Post Feb 23rd 2012
Blog Task: The Never Ending Algorithm
TheEnd.exe
I liked this exe as it showed the application of a never ending loop
Clicking the “Ends” button displayed a message box,
“This is a repeating message box with an end”, and an ok button.
The ok button had to be clicked twice for the message box to close
Clicking the “Never Ends” button displayed and message box,
“This is a repeating message box that never ends (you will need to click the stop button to end)”, and an ok button.
No matter how many times the ok button was clicked, the message box never closed.
Clicking the red X would not close the message bow either.
The only way to stop the program was to start the task manager, (Ctrl + Alt + Del), and End Task.
Original Post Feb 23rd 2012
What is an Algorithm?
An Algorithm is a step by step formula that must used to determine the solution for a problem or task.
In every day terms an Algorithm is a cooking recipe or a step by step work procedure that is followed to ensure a correct outcome.
http://dictionary.reference.com/browse/algorithm
http://www.webopedia.com/TERM/A/algorithm.html
http://en.wikipedia.org/wiki/Algorithm
http://www.merriam-webster.com/dictionary/algorithm
Original Post Feb 13th 2012
Subscribe to:
Posts (Atom)