使用while语句,分别求1到100的奇数和 和 偶数和
public class TestWhile{ public static void main(String[] args){ int i = 1; int sum = 0; while(i<100){ sum+=i; i+=2; } System.out.println("1-100的奇数和为sum = "+sum); System.out.println("--------------------------------------- "); int j = 1; sum = 0; while(j <= 100){ if(j%2 == 0){ sum+=j; } j++; } System.out.print("1-100的偶数数和为sum = "+sum); } }