展开全部
完整代码如636f707962616964757a686964616f31333337383337下,在eclipse中运行。/**
* 三种不同的java循环语句计算1到1000之间能被7和11同时整除的整数之和
* @author young
*
*/
public class Exam {
public static void main(String[] args){
int forsum = 0 ,wsum = 0 ,dwsum = 0;
int i = 1,j = 1,k = 1;
//for循环
for(i = 1 ; i <= 1000 ; i++){
if(i % 7 == 0 && i % 11 == 0){
forsum = forsum + i ;
}
}
System.out.println("For循环的结果: " + forsum);
//while循环
while(j <= 1000){
if(j % 7 == 0 && j % 11 == 0){
wsum = wsum + j ;
}
j ++ ;
}
System.out.println("while循环结果为:" + wsum);
//do...while循环
do{
if( k % 7 == 0 && k % 11 == 0 ){
dwsum = dwsum + k ;
}
k ++ ;
}while(k <= 1000);
System.out.println("do...while循环结果为:" + dwsum);
}
}