

2024-06-23
Presentation
•
Computers
•
11th Grade
•
Practice Problem
•
Easy
Arasaka Teacher
Used 1+ times
FREE Resource
1 Slide • 5 Questions
1
9618-paper2
By Arasaka Teacher
2
Open Ended
public class AlgorithmExample {
public static void main(String[] args) {
int[] data1 = {1, 2, 3, 4};
int[] data2 = {5, 6, 7, 8};
// 计算 data1 的平方和
int sum1 = 0;
for (int num : data1) {
sum1 += num * num;
}
System.out.println("data1 的平方和: " + sum1);
// 计算 data2 的平方和
int sum2 = 0;
for (int num : data2) {
sum2 += num * num;
}
System.out.println("data2 的平方和: " + sum2);
}
}
3
Drag and Drop
The calculateSquareSum method can be called anywhere in the program without
If the calculation logic needs modification (e.g., changing to cube sum num num num), only the calculateSquareSum method needs adjustment,
The main program logic becomes clearer and easier to understand, as complex algorithms are abstracted into dedicated methods.
4
Reorder
————————:
Look at the code that is used in many places and does the same calculation.
————————:
Create a new method (or function) and put the repeated code inside it.
Make sure this method can take different data, such as an array of numbers.
————————:
Let the method give back the result of the calculation so the rest of the program can use it.
————————:
Replace the old repeated code with calls to the new method.
Send the needed data to the method when calling it.
——:
Verify that the new method works correctly with various inputs.
Ensure that the overall program behaves as expected after the modification.
Find the Repeated Code
Make a New Method
Return the Result
Use the New Method
Test and Validate
5
Dropdown
List the Variables:
Write down all variables you will use. For example:
declare A, B, C
Initialization:
Remember to initialize variables. For example:
initialize A to 0
2.
Identify Needed Structures:
Decide if you need an array, a record, or a file. For example:
declare an array called Numbers
or
declare a record called Student
3.
Loops and Repetition:
Describe how the loop works. For example:
For Loop: “set a
If your program uses a file, include steps like:
open file in read mode
read data from the file
close the file
6
Dropdown
Assignment and Calculation:
For assignment, use words like “set” or “assign”.
Example: “assign A to B”
For addition: “calculate the new value of C by adding A to B”
For subtraction: “calculate the new value of C by subtracting A from B”
For multiplication: “calculate the new value of C by multiplying A by B”
For division: “calculate the new value of C by dividing A by B”
Example: “obtain the new string by concatenating A with B, and assign the new string to Variable2.”
Prompting the User:
Always include a prompt when the program should ask for user input.
Example: “display prompt 'Enter a number:'”
5.
Write “end while” or “next i” after the loop to show it ends.
Always indicate when a block of instructions is finished.
6. Using Functions (if any)
Call Functions Clearly:
Example: “use the function INT() to obtain the whole number part of the digit.”
9618-paper2
By Arasaka Teacher
Show answer
Auto Play
Slide 1 / 6
SLIDE
Similar Resources on Wayground
1 questions
Sample
Presentation
•
KG
1 questions
Which is better
Presentation
•
KG
8 questions
Practice reading comprehension
Presentation
•
11th - 12th Grade
6 questions
Буквица как искусство
Presentation
•
10th Grade
3 questions
Personality Tests Student Survey
Presentation
•
11th Grade
7 questions
Inductive Reasoning
Presentation
•
10th - 11th Grade
5 questions
Unit 2 MS Acess 2007
Presentation
•
11th Grade
2 questions
Thursday, September 7 - Review Day
Presentation
•
11th Grade
Popular Resources on Wayground
20 questions
STAAR Review Quiz #3
Quiz
•
8th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
6 questions
Marshmallow Farm Quiz
Quiz
•
2nd - 5th Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
20 questions
Inferences
Quiz
•
4th Grade
19 questions
Classifying Quadrilaterals
Quiz
•
3rd Grade
12 questions
What makes Nebraska's government unique?
Quiz
•
4th - 5th Grade
Discover more resources for Computers
20 questions
Grammar
Quiz
•
9th - 12th Grade
31 questions
Easter Trivia
Quiz
•
KG - 12th Grade
16 questions
Circles - Equations, Central & Inscribed Angles
Quiz
•
9th - 12th Grade
46 questions
Unit 4 Geosphere Test Review
Quiz
•
9th - 12th Grade
25 questions
Early Cold War Quizziz
Quiz
•
11th Grade
10 questions
Climate Change and Its Impact
Interactive video
•
9th - 12th Grade
35 questions
Venn Diagrams, Theoretical, & Experimental Review
Quiz
•
9th - 12th Grade
20 questions
Food Chains and Food Webs
Quiz
•
7th - 12th Grade