![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
循环结构
懒人爱睡觉
这个作者很懒,什么都没留下…
展开
-
提示客户输入一个月份,必须在1~12月之间,如果输入错误就让客户重新输入,然后根据月份输出季节,3~5为春天,6~8为夏天,9~11月为秋天,12~2为冬天。
import java.util.Scanner; public class WhileMonth { public static void main(String[] args) { Scanner input = new Scanner(System.in); int month; boolean isRight; do{ System.out.println(“请输入月份(1-12月):”)...原创 2019-10-19 20:41:40 · 2018 阅读 · 0 评论 -
2015年父亲30岁,儿子6岁,问多少年后父亲的年龄是儿子的两倍?
//while循环 public class For { public static void main(String[] args) { int year=2015; int father=30; int son=6; while(father!=son*2){ year++; father++; son++; } } } System.out.println(year+“年,父亲是”+fath...原创 2019-10-19 20:35:22 · 1564 阅读 · 0 评论