❶ 编写java程序,分别应用while语句、do-while语句,求出100以内所有奇数的和
whileint i=1;
int result=0;
while(i<=100){
result+=i;
i+=2;
}
System.out.println("100内奇数和为:"+result);
do{}while{}
int i=1;
int result=0;
do {
result+=i;
i+=2;
}while (i<=100);
System.out.println("100内奇数和为:"+result);