CS计算机代考程序代写 Java // WhileExample.java – Demonstrates the use of while

// WhileExample.java – Demonstrates the use of while
class WhileExample {
public static void main(String args[]) {
int sum = 0, n = 1;
while ( n <= 10) { sum = sum + n; n = n + 1; } System.out.println("Sum = " + sum); } }