当前位置: 首页 > news >正文

if结构

if 单选择结构

image

package com.guo.struct;import java.util.Scanner;public class ifDemo01 {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);System.out.println("请输入内容: ");String s = scanner.nextLine();//判断字符串是否一致if (s.equals("hello")){System.out.println(s);}System.out.println("END");scanner.close();}
}

if 双选择结构

image

package com.guo.struct;import java.util.Scanner;public class ifDemo02 {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);System.out.println("请输入成绩");int score = scanner.nextInt();if (score>=60){System.out.println("及格");}else{System.out.println("不及格");}scanner.close();}
}

if 多选择结构

image

package com.guo.struct;import java.util.Scanner;public class ifDemo03 {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);/*if 语句中至多有一个 else 语句,else 语句在所有 else if 语句之后if 语句可以有若干个 else if 语句,他们必须在 else 语句之前一旦一个 else if 语句检测为 true,其他的 else if 以及 else 语句都将跳出执行*/System.out.println("请输入成绩: ");int score = scanner.nextInt();if (score==100){System.out.println("满分");}else if(score>=90 && score<100){System.out.println("A级");}else if(score>=80 && score<90){System.out.println("B级");}else if(score>=70 && score<80){System.out.println("C级");}else if(score>=60 && score<70){System.out.println("D级");}else if(score>=0 && score<60) {System.out.println("不及格");}else if(score>=60 && score<70) {System.out.println("A级");}else {System.out.println("成绩不合法");}scanner.close();}}

if 嵌套结构

image

http://www.jsqmd.com/news/424533/

相关文章:

  • 流水线智能熔断:基于机器学习的自动化阻塞预测模型
  • 交稿前一晚!9个AI论文软件深度测评:本科生毕业论文写作必备工具推荐
  • 2025年12月口碑优选!光伏电源厂商排行榜出炉,辅助应急电源/军用电源/全国产化电源/光伏电源,光伏电源公司推荐榜单 - 品牌推荐师
  • 2026年生产管理软件供应服务商排名,口碑好的有哪些 - 工业品牌热点
  • 效能度量黑洞:如何避免测试指标沦为无效 KPI 游戏?
  • 海外口碑氢氧化镁厂家:2026年选购新参考,氢氧化镁企业口碑推荐榜精选综合实力企业 - 品牌推荐师
  • 沉睡的携程礼品卡别浪费!可可收一键回收,高效又靠谱 - 可可收
  • 分析卤素水分测定仪生产工厂,如何选择性价比高的产品 - 工业推荐榜
  • 破茧:基于价值流分析的软件测试活动裁剪模型研究
  • ZICbA构思 建筑经验手册
  • 2026白玉兰广场户外LED大屏广告,承包商服务盘点,上海震旦大厦广告,户外led大屏广告代理公司折扣 - 品牌推荐师
  • C#AI系列:从零开始打造自己的OpenClaw
  • 2026年有名的哈尔滨交通事故律师事务所/哈尔滨劳动纠纷律师事务所精选服务推荐 - 行业平台推荐
  • 2026年热门的注塑机清洗料/挤出机清洗料值得信赖的生产厂家 - 行业平台推荐
  • 吐血推荐 8个AI论文工具:MBA毕业论文写作全维度测评
  • 第 3 篇:性能优化实战:Lighthouse 95+ 分的秘密
  • P9953 [USACO20OPEN] Social Distancing II B
  • 2026年知名的不锈钢液压铰链/阻尼液压铰链生产厂家推荐几家 - 行业平台推荐
  • 2026冲刺用!10个AI论文工具测评:专科生毕业论文+开题报告高效写作指南
  • 第 1 篇:10 分钟用 Next.js + Vercel 搭建现代化网站
  • 实测才敢推!MBA专属降AIGC平台 —— 千笔·专业降AIGC智能体
  • 2026年精通学区房业务的中介哪家好,学区房划片范围每年会变吗 - mypinpai
  • 2026年资质齐全的美陈设计制作专业公司,服务甘肃等地超靠谱 - 工业设备
  • 2026年评价高的ENF级除醛生态板/环保生态板高口碑品牌推荐 - 行业平台推荐
  • 梳理2026年适合家庭的咖啡机,Nordtika咖啡机咖啡豆兼容性好吗探讨 - 工业设备
  • 2026年咖啡机品牌哪家口碑好,Nordtika专业可靠受青睐 - 工业品网
  • 普通人也能懂的敏捷思维:破解团队内耗,快速提升效率
  • 教你京东E卡回收,轻松赚现金! - 团团收购物卡回收
  • 2026年免清洗油烟机源头厂家排名,选购时怎么选择 - 工业品网
  • [CF1618G] TraderProblem 题解