public class WhileTest03 {
public static void main(String[] args) {
int i = 0;
int sum = 0;//计算总和
int sumodd = 0;//计算奇数的和
int sumeven = 0;//计算偶数的和
while (i <= 100) {
sum += i;
if (i % 2 == 0) {
//偶数
sumeven += i;
} else {
//奇数
sumodd += i;
}
i++;
}
System.out.println("总和为:" + sum);
System.out.println("奇数的和为:" + sumodd);
System.out.println("偶数的和为:" + sumeven);
}
}