URI Problem (Sum of Consecutive Even Numbers) 1159:
Sum of Consecutive Even Numbers is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.
import java.util.Scanner; /** * @Author : Muhammad Harun-Or-Roshid * @Date : Oct 22, 2016 * @Time : 11:34:44 AM */ public class Uri1159 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { int x = sc.nextInt(); int count = 0, total = 0; if (x == 0) { break; } else { while (count < 5) { if (x % 2 == 0) { total += x; count++; } x++; } System.out.println(total); } } } }