Algorithms
Algorithms
● Step 3.1. Declare integer variables "num", "i", "j", and "temp".
● Step 3.2. Create a Scanner object "input".
● Step 3.3. Prompt the user to enter the number of integers to sort and read it into "num".
● Step 3.4. Declare an integer array "array" of size "num".
● Step 3.5. Prompt the user to enter "num" integers and read them into the array.
Step 4. Use a for loop to iterate from 0 to (num - 1) (let's call this loop index "i"):
● Step 4.1. Inside this loop, use another for loop to iterate from 0 to (num - i - 1) (let's call
this loop index "j"):
○ Step 4.1.1. If "array[j]" is greater than "array[j + 1]", swap the two elements:
■ Step 4.1.1.1. Set "temp" to "array[j]".
■ Step 4.1.1.2. Assign "array[j + 1]" to "array[j]".
■ Step 4.1.1.3. Assign "temp" to "array[j + 1]".
Step 5. After sorting, print the sorted list of integers by iterating through
the "array".
Step 6. End of the method.
Step 7. End of the class.
EmployeeTax
Step 1. Import the java.util.Scanner package.
Step 2. Declare a public class named "EmployeeTax".
Step 3. Define a method "tax" that takes a String parameter "name" and an integer parameter
"income":
Step 2. Prompt the user to enter the values of xxx and nnn.
Step 3. Read the integer value for xxx from user input.
Step 4. Read the integer value for nnn from user input.
Step 5.2. If iii is greater than 0, loop from j=1j = 1j=1 to j=ij = ij=i:
Step 5.4. Add the calculated term to sum (i.e., sum = sum + (Math.pow(x, i)) / f).
Step 6. After the loop ends, print the value of sum as the result.
Step 7. End.