package Home;
public class Home {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int a = 0, b = 0;
do {
if (a % 3 == 0) {
b = b + a;
}
a++;
} while (a <= 100);
System.out.println("能被三整除的和为"+b);
}
}
![](https://img2020.cnblogs.com/blog/2318909/202104/2318909-20210402162943543-1041788423.png)
package Home;
public class Home {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int b = 0;
for (int i = 0; i < 101; i++) {
if (i % 3 == 0) {
b = b + i;
}
}
System.out.println("能被三整除的和为" + b);
}
}
![](https://img2020.cnblogs.com/blog/2318909/202104/2318909-20210402163142555-1526044950.png)
package Home;
public class Home {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int a = 0, b = 0;
while (a <= 100) {
if (a % 3 == 0) {
b = b + a;
}
a++;
}
System.out.println("能被三整除的和" + b);
}
}
![](https://img2020.cnblogs.com/blog/2318909/202104/2318909-20210402163255068-606478756.png)
package Home;
public class Home {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
for (int i = 0; i < 10; i++) {
if (i != 5) {
System.out.println(i);
}
}
}
}
![](https://img2020.cnblogs.com/blog/2318909/202104/2318909-20210402163746659-434672162.png)
package Home;
import java.util.Scanner;
public class Home {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input=new Scanner(System.in);
System.out.println("请输入一个数字");
int n=input.nextInt();
int sum=1;
for (; n>0; n--) {
sum=sum*n;
}
System.out.println("该数的阶乘为"+sum);
}
}
![](https://img2020.cnblogs.com/blog/2318909/202104/2318909-20210402164815570-1776259525.png)
package Home;
import java.util.Scanner;
public class Home {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
for (;;) {
System.out.println("请输入学生成绩");
int i = input.nextInt();
if (i < 0 || i > 100) {
System.out.println("输入错误");
} else {
System.out.println("输入成功");break;
}
}
}
}
![](https://img2020.cnblogs.com/blog/2318909/202104/2318909-20210402170158561-1029151360.png)
package Home;
public class Home {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
double sum = 0;
double money = 30000;
for (int i = 0; i < 10; i++) {
money = money * 1.06;
sum = sum + money;
}
System.out.println("该员工十年后的年薪为" + (int) money + "总收入为" + (int) sum);
}
}
![](https://img2020.cnblogs.com/blog/2318909/202104/2318909-20210402171802893-836493074.png)
package Home;
public class Home {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int a,b,c;
for (int d=100;d<1000;d++) {
a=d/100;
b=d/10%10;
c=d%10;
if (a*a*a+b*b*b+c*c*c==d) {
System.out.println("所有的水仙数为"+d);
}
}
}
}
![](https://img2020.cnblogs.com/blog/2318909/202104/2318909-20210402172636788-1706380929.png)
package Home;
import java.util.Scanner;
public class Home {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input=new Scanner(System.in);
System.out.println("请输入年份");
int year=input.nextInt();
System.out.println("请输入月份");
int month=input.nextInt();
System.out.println("请输入天数");
int day=input.nextInt();
int sum=0;
int days;
for (; month-1 >0 ; month--) {
if(month-1==1||month-1==3||month-1==5||month-1==7||month-1==8||month-1==10){
days=31;
}else if(month-1==4||month-1==6|month-1==9||month-1==11){
days=30;
}else if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0
&& month-1 == 2) {
System.out.println("该年为闰年");
days = 29;
} else {
days = 28;
}
sum=sum+days;
}
sum=sum+day;
System.out.println("今天是"+year+"年的第"+sum+"天");
}
}
![](https://img2020.cnblogs.com/blog/2318909/202104/2318909-20210402180814579-208122344.png)
package Home;
import java.util.Scanner;
public class Home {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input=new Scanner(System.in);
System.out.println("请输入一个四位整数");
int num=input.nextInt();
int[ ] a=new int[4];
for (int i = 0; i < 4; i++) {
a[i]=num%10;
num=num/10;
}
System.out.println(a[0]*1000+a[1]*100+a[2]*10+a[3]);
}
}
![](https://img2020.cnblogs.com/blog/2318909/202104/2318909-20210402182658056-529286660.png)