Answer:
class TriangleNumbers
{
public static void main (String[] args)
{
for (int number = 1; number <= 10; ++number) {
int sum = 1;
System.out.print("1");
for (int summed = 2; summed <= number; ++summed) {
sum += summed;
System.out.print(" + " + Integer.toString(summed));
}
System.out.print(" = " + Integer.toString(sum) + '\n');
}
}
}
Explanation:
We need to run the code for each of the 10 lines. Each time we sum numbers from 1 to n. We start with 1, then add numbers from 2 to n (and print the operation). At the end, we always print the equals sign, the sum and a newline character.
Answer:
sum2 = 0
counter = 0
lst = [65, 78, 21, 33]
while counter < len(lst):
sum2 = sum2 + lst[counter]
counter += 1
Explanation:
The counter variable is initialized to control the while loop and access the numbers in <em>lst</em>
While there are numbers in the <em>lst</em>, loop through <em>lst</em>
Add the numbers in <em>lst</em> to the sum2
Increment <em>counter</em> by 1 after each iteration
Answer: The accelerator and the brakes.
Answer:
Force magnitude = 296.7 N
Explanation:
Detailed illustration is given in the attached document.