gunnersforlife04
gunnersforlife04 gunnersforlife04
  • 14-01-2021
  • Computers and Technology
contestada

wap in java to complete the following (16*1) +(14*2) +(12*3) +(10*4) +(8*5) +(6*6) +(4*7)​

Respuesta :

Tsarina
Tsarina Tsarina
  • 14-01-2021

Answer:

It goes like:

public class Program

{

public static void main(String[] args)

{

int j=18;

int sum=0;

for (int i =1; i<7; i++)

{

sum=sum+(i*(j-2));

j=j-2;

}

System.out.println(sum);

}

}

Explanation:

Variables used:

j : controls the first number in product and decreases by 2 each time the loop runs.

sum: saves the values of addition as the loop runs.

Answer Link

Otras preguntas

The length of rectangle B is 25% greater than the length of rectangle A. The width of rectangle B is 3/5 X the width of rectangle A. Find the fraction Area of
How do I set up this problem. I'm lost
Dehydration in the human body and weight loss due to dehydration is serious because the human body is Select one: O 1.33 percent water O 2.40 - 50 percent water
Ideas and religions also spread along trade routes. What evidence do you see that support this?
50. If Ken is taller than Scott, then Dale is shorter than Connie. Which of the following must be true?the correct answer is E​
A new car sells for $27,500. The value of the car decreases by 14% annually. You want to sell the car when it's worth about $4000. Explain how many years you wi
What was one reason that the constitutional convention decided they needed a document to replace articles of confederation? A. Because the country needed a docu
14mm equal to how much cm​
Please help me asap!
Please help if you watch/read Romeo and Juliet ty