

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
6 questions
Jesus Institutes the Church
Presentation
•
11th Grade
7 questions
Windows Desktop Elements
Presentation
•
12th Grade
3 questions
Digital Footprint
Presentation
•
11th Grade
5 questions
Excel Lesson 3
Presentation
•
11th Grade
5 questions
Desain Grafis Percetakan
Presentation
•
11th Grade
6 questions
INFORMATIKA
Presentation
•
10th Grade
8 questions
Digitális platformok online workshop
Presentation
•
KG
8 questions
ICS3U Lesson 1: Creating Java Application - Displaying Output
Presentation
•
11th Grade
Popular Resources on Wayground
28 questions
US History Regents Review
Quiz
•
11th Grade
36 questions
Biology Regents Review
Quiz
•
9th - 10th Grade
20 questions
Math Review
Quiz
•
3rd Grade
38 questions
Regents Life Science General Review
Quiz
•
9th Grade
20 questions
Math Review
Quiz
•
6th Grade
21 questions
EOY Grade 6 Benchmark Assessment - Content Skills
Quiz
•
6th Grade
20 questions
Inferences
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
Discover more resources for Computers
28 questions
US History Regents Review
Quiz
•
11th Grade
45 questions
Earth and Space Science Regents: Exam Cram
Presentation
•
7th - 12th Grade
35 questions
US History - Regents Review - President, Amendments, Court Cases
Quiz
•
11th Grade
50 questions
US History Comprehensive Final Exam
Quiz
•
9th - 12th Grade
50 questions
US History Regents Practice Exam
Quiz
•
11th Grade
30 questions
US History Regents Review #3
Quiz
•
11th Grade
16 questions
TSI Math 2.0 Practice
Quiz
•
9th Grade - University
25 questions
US History Regents Review # 1
Quiz
•
11th Grade