Java100例题(一)
【摘要】 1,编写程序,判断给定的某个年份是否是闰年。
闰年的判断规则如下: (1)若某个年份能被 4 整除但不能被 100 整除,则是闰年。
(2)若某个年份能被 400 整除,则也是闰年。
// 必须秒杀
import java.util.Scanner;
public class Bissextile { public static void main(String...
1,编写程序,判断给定的某个年份是否是闰年。
闰年的判断规则如下:
(1)若某个年份能被 4 整除但不能被 100 整除,则是闰年。
(2)若某个年份能被 400 整除,则也是闰年。
// 必须秒杀
import java.util.Scanner;
public class Bissextile { public static void main(String[] args) { System.out.println("请输入年份"); int year; Scanner in = new Scanner(System.in); year = in.nextInt(); if (year<0|| year>3000){ System.out.println("年份有误,程序退出"); System.exit(0); } if ((year%4==0)&&(year%100!=0)||(year%400==0)){ System.out.println(year + "\t"+ "is 闰年"); } else System.out.println(year + "\t"+ "isn't 闰年"); }
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
2,给定一个百分制的分数,输出相应的等级。
- 90 分以上 A 级
- 80~89 B 级
- 70~79 C 级
- 60~69 D 级
- 60
文章来源: maoli.blog.csdn.net,作者:刘润森!,版权归原作者所有,如需转载,请联系作者。
原文链接:maoli.blog.csdn.net/article/details/102586274
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)