zhouzetian

1:编写程序,判断给定的某个年份是否是闰年。

闰年的判断规则如下:(1)若某个年份能被4整除但不能被100整除,则是闰年。(2)若某个年份能被400整除,则也是闰年。

import java.util.Scanner;

class Bissextitle{

        public static void main(string[]args){

                 Scanner scanner=new scanner(system.in);

                 System.out.println("请输入年份");

                 int year;

                year=scanner.nextInt();

                if(year>3000||year<0){

                       System.out.println("你输入的年份有误");

                        System.exit(0);

                                                 }

               if(year%400==0||((year%4==0)&&(year%100!=0))

                      System.out.println("this year is bissextitle");

               else

                      System.out.println("this year is not bissextitle);

           }

}

2:根据一个百分制的分数,输出对应的等级

90分及以上  A级;80---90 B级 ; 60---80 C级;  0--60   D级。

import java.util.Scanner;

public class  Mark{

          public static void main(string[]args){

                  Scanner scanner=new scanner(system.in);

                   System.out.println("请输入分数");
                  double mark;

                 mark=Scanner.nextDouble();

                if(mark>100||mark<0){

                             System.out.println("输入分数有误");

                             System.exit(0);

                                     }

                 if(mark>=90)  System.out.println("this mark is grade \'\A\\'");

                 else if(mark>=80&&mark<90) System.out.println("this mark is grade \'\B\\'");

                 else  if(mark>=60&&mark<80) System.out.println("this mark is grade \'\C\\'");

                 else (mark<60) System.out.println("this mark is grade \'\D\\'");

}

}

3.编写1+3+5+.....+99的和

class he{

          public static void main(string[]args){

                    int number,sum=0;

                    for(number=1;number<100;number+=2)

                                         sum+=number;

                     System.out.println("1+3+5+.....+99的和:“+sum);

         }

}

4。编写9X9乘法口诀表

public class NineNine{

          public static void main(string[]args){

                    System.out.println();

                   for(int i=1;i<10;i++){

                           for( int j=1;j<10;j++){

                            if (j>i) break;

                            System.out.println(" "+i+"X"+k+" ”);

          }

         System.out.println();

                    }

               }

}

 

 JAVA面向对象经典程序

1:hello world例子

 

2:类的基本组成示例

3:静态和非静态变量及方法的使用

4:类继承的例子

5:类的访问修饰符

6:抽象类及其实例展示

 

 

              

 

 

                  

                          

                

分类:

技术点:

相关文章:

  • 2022-02-01
  • 2021-11-11
  • 2021-11-30
  • 2021-08-25
  • 2021-07-27
  • 2022-12-23
  • 2021-11-11
  • 2021-11-11
猜你喜欢
  • 2021-09-02
  • 2021-09-27
  • 2021-09-27
  • 2021-12-13
  • 2021-11-13
  • 2022-02-08
相关资源
相似解决方案