Tuesday, July 28, 2009

Write an java application that calculates the sum of all the even numbers?

Write an java application that calculates the sum of all the even numbers between 0 to n, where n is given by the user.

Write an java application that calculates the sum of all the even numbers?
prompt user for ending point first then


evenSum;


count = 0;


while(count %26lt;= endPoint){


count++;


if(count % 2 == 0){


evenSum = count + evenSum;


System.out.println(count); //Only if you have to show the even numbers as it adds


}


then output evenSum

tomato plants

No comments:

Post a Comment