package fee;
import java.util.Scanner;
import org.junit.Test;
public class Jtest {
@Test
public void test1(){
int i = 0;
while(i<=100){
if(i%2==0){
System.out.print(i+" ");//输出0-100所有的偶数
}
i=i+1;
}
}
@Test
public void test2(){
int i=0;
int sum=0;
while(i<=100){
sum=sum+i;//0-100的和
i++;
}
System.out.println(sum);
}
@Test
public void test3(){
for(int i=0;i<=100;i++){
if(i%2==0){
System.out.print(i+" ");//输出0-100所有的偶数(1)
}
}
}
@Test
public void test4(){
for(int i=0;i<=100;i+=2){ //输出0-100所有的偶数(2)
System.out.print(i+" ");
}
}
@Test
public void test5(){
int sum=0;
for(int i=0;i<=100;i++){
if(i%2==0){
sum=sum+i; //0-100偶数的和
}
}
System.out.println(sum);
}
@Test
public void test6(){
int sum=0;
for(int i=1;i<=100;i+=2){
sum=sum+i; //0-100奇数的和(1)
}
System.out.println(sum);
}
@Test
public void test7(){
int sum=0;
for(int i=0;i<=100;i++){
if(i%2==1){
sum=sum+i; //0-100奇数的和(2)
}
}
System.out.println(sum);
import java.util.Scanner;
import org.junit.Test;
public class Jtest {
@Test
public void test1(){
int i = 0;
while(i<=100){
if(i%2==0){
System.out.print(i+" ");//输出0-100所有的偶数
}
i=i+1;
}
}
@Test
public void test2(){
int i=0;
int sum=0;
while(i<=100){
sum=sum+i;//0-100的和
i++;
}
System.out.println(sum);
}
@Test
public void test3(){
for(int i=0;i<=100;i++){
if(i%2==0){
System.out.print(i+" ");//输出0-100所有的偶数(1)
}
}
}
@Test
public void test4(){
for(int i=0;i<=100;i+=2){ //输出0-100所有的偶数(2)
System.out.print(i+" ");
}
}
@Test
public void test5(){
int sum=0;
for(int i=0;i<=100;i++){
if(i%2==0){
sum=sum+i; //0-100偶数的和
}
}
System.out.println(sum);
}
@Test
public void test6(){
int sum=0;
for(int i=1;i<=100;i+=2){
sum=sum+i; //0-100奇数的和(1)
}
System.out.println(sum);
}
@Test
public void test7(){
int sum=0;
for(int i=0;i<=100;i++){
if(i%2==1){
sum=sum+i; //0-100奇数的和(2)
}
}
System.out.println(sum);
}
}