刚学if else 用的不好 各位大神不要见笑
来源:互联网 发布:网易云音乐数据库 编辑:程序博客网 时间:2024/06/05 02:53
// 输入一个4位数判断一个数是否是玫瑰花数
//(a*a*a*a+b*b*b*b+c*c*c*c+d*d*d*d=i)
import java.util.*;public class HomeWork1 {public static void main(String[] args) {System.out.println("请输入一个四位数的整数:");Scanner sc = new Scanner(System.in);int i = sc.nextInt();int a = i % 10;int b = i / 10 % 10;int c = i / 100 % 10;int d = i / 1000 % 10;if (i >= 1000 && i < 10000) {if ((a * a * a * a + b * b * b * b + c * c * c * c + d * d * d * d) == i) {System.out.println("是玫瑰花数!");} else {System.out.println("不是玫瑰花数!");}} else {System.out.println("你输入的不是四位数的整数!");}}}
// 输入考试分数判断学生的成绩
import java.util.*;public class HomeWork1 {public static void main(String[] args) {System.out.println("请输入成绩:");Scanner sc = new Scanner(System.in);int score = sc.nextInt();if (score < 60) {System.out.println("不及格,再努力!");} else if (score < 70) {System.out.println("及格!");} else if (score < 80) {System.out.println("良好!");} else if (score <= 100) {System.out.println("优秀!");} else {System.out.println("输入错误!");}}}
// 输入一个年份判断是否是闰年
//(能被4整除不能被100整除或者能被400整除的数)
import java.util.*;public class HomeWork1 {public static void main(String[] args) {System.out.println("请输入年份:");Scanner sc = new Scanner(System.in);int i = sc.nextInt();if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {System.out.println("是闰年!");} else {System.out.println("不是闰年!");}}}
/* 个人所得税计算器
个人所得税税率表一(工资、薪金所得适用)
级数 全月应纳税所得额 税率(%)
1 不超过1500元的 3
2 超过1500元至4500元的部分 10
3 超过4500元至9000元的部分 20
4 超过9000元至35000元的部分 25
5 超过35000元至55000元的部分 30
6 超过55000元至80000元的部分 35
7 超过80000元的部分 45
*/
import java.util.*;public class HomeWork1 {public static void main(String[] args) {System.out.println("请输入你的工资:");Scanner sc = new Scanner(System.in);int wage = sc.nextInt();int i = wage - 3500;double a = 0;if (i <= 0) {System.out.println("工资连3500都不到,不用交税了!");} else if (i <= 1500) {a = i * 0.03;} else if (i <= 4500) {a = 1500 * 0.03 + (i - 1500) * 0.1;} else if (i <= 9000) {a = 1500 * 0.03 + (4500 - 1500) * 0.1 + (i - 4500) * 0.2;} else if (i <= 35000) {a = 1500 * 0.03 + (4500 - 1500) * 0.1 + (9000 - 4500) * 0.2+ (i - 9000) * 0.25;} else if (i <= 55000) {a = 1500 * 0.03 + (4500 - 1500) * 0.1 + (9000 - 4500) * 0.2+ (35000 - 9000) * 0.25 + (i - 35000) * 0.3;} else if (i <= 80000) {a = 1500 * 0.03 + (4500 - 1500) * 0.1 + (9000 - 4500) * 0.2+ (35000 - 9000) * 0.25 + (55000 - 35000) * 0.3+ (i - 55000) * 0.35;} else {a = 1500 * 0.03 + (4500 - 1500) * 0.1 + (9000 - 4500) * 0.2+ (35000 - 9000) * 0.25 + (55000 - 35000) * 0.3+ (80000 - 55000) * 0.35 + (i - 80000) * 0.45;}System.out.println("你应该交税为:" + a);System.out.println("你交税后的工资为:" + (wage - a));}}
阅读全文
0 0
- 刚学if else 用的不好 各位大神不要见笑
- 不要if else的编程
- 能用if- else/throw-exception进行错误/异常处理的地方就不要用assert。
- 为什么使用if else分支语句不好
- 可新可新的新手刚刚上路,学C语言,见笑了,大神不用来了。(内有break与continue)
- VS2012+SQL2008+ODBC编程,第一篇博客,写的不好忘各位大神指点一二~
- 求各位的大神
- if......if和if......else if......else if的区别
- if , if else , if else if , if的嵌套
- 刚学ACCESS2007 有问题请教各位!
- if,else if,else的执行
- if else if else 语句的拓展
- if;if else;if else if 循环结构的用法
- Oracle的if else if...
- 刚学 RMQ 求大神指点
- 用if else 完成成绩的分布
- Velocity的if...else
- if else的使用
- apache2 服务器模块文件配置
- JDK各个版本的新特性jdk1.5-jdk1.8
- [C#]利用EasyHook创建安装本地钩子[教程翻译+理解]
- 转型
- [LeetCode]Integer to Roman
- 刚学if else 用的不好 各位大神不要见笑
- 移动端多指触屏事件兼容
- 在centos环境下部署yara
- HttpClient发送HTTP请求
- Battle test(Locust and Apache Bench)
- chartjs图标插件
- iOS 多语言版本的开发(三)
- 常见的汉字字符集编码
- html学习笔记之一:表单控件