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

Circle the one that is not a mental health professional: counselor sociologist psychologist social worker psychiatrist
3 Read these sentences from the text: "Veterans Day originated as 'Armistice Day' on Nov. 11, 1919, the first anniversary of the end of World War I. Congress pa
what kind of landscapes does winnipeg have?
There are a total of 24 people at Camp Float-Away. If 4 of the people are counselors, what is the ratio of campers to counselors?
What is the mean of 3,4.5,6.5,8,8.5, & 10
If a rock is dropped from the top of a tower at the front of it and takes 3.6 seconds to hit the ground. Calculate the final velocity of the penny in m/s. What
please help!!!!!! 26 points and Brianliest​
The equation of the line in the graph is y= (blank) x+ (blank)
Type the correct answer in the box. Spell all words correctly. What is the term for the account balances of commercial banks held by the central bank? The accou
Solve * (7 Points) 9a + 28 = 4a +3 A -30 B 20 C 6.2 D -5