Java Programming

WAP to print sum and average of multiples of 5 from 500 to 600?

Answer

Wiki User
01/02/2009

public class Test {

public static void main(String[] args){

int i = 500;

int sum = 0;

int avg = 0;

int counter = 0;

do {

i = i + 5;

sum = sum + i;

counter = counter + 1;

} while (i <= 600);

System.out.println("Sum: " + sum);

avg = sum/counter;

System.out.println("Average: " + avg);

}

}