

2024-06-23
Presentation
•
Computers
•
11th Grade
•
Practice Problem
•
Easy
Arasaka Teacher
Used 1+ times
FREE Resource
1 Slide • 5 Questions
1
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.”
By Arasaka Teacher
Show answer
Auto Play
Slide 1 / 6
SLIDE
Similar Resources on Wayground
5 questions
Quizizz Python Lesson 1
Presentation
•
11th Grade
4 questions
Peer to Peer Networking
Presentation
•
11th - 12th Grade
6 questions
Uniqueness of Earth: Quiz
Presentation
•
11th Grade
1 questions
Groundhog poll.
Presentation
•
KG
7 questions
Synonyms and Antonyms
Presentation
•
10th - 12th Grade
8 questions
Feedback loops for Global Warming
Presentation
•
11th - 12th Grade
6 questions
MAC 2 | Lesson 5-7 | Wrap it Up
Presentation
•
KG
7 questions
cycle 2
Presentation
•
11th - 12th Grade
Popular Resources on Wayground
10 questions
Safety Day 2026 – Student Review
Quiz
•
9th Grade
21 questions
Continents and Oceans
Quiz
•
6th Grade
20 questions
Parts of Speech
Quiz
•
5th Grade
16 questions
Subject & Predicate
Quiz
•
5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
12 questions
Map Skills
Quiz
•
3rd Grade
22 questions
Continents and Oceans
Quiz
•
5th Grade
15 questions
Rounding Decimals
Quiz
•
5th Grade