package struct;
import java.util.Scanner;
//if 单选择结构
public class IfDemon01 {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
System.out.println("请输入内容");
String str=scanner.nextLine();
//equals:判断字符串是否相等
if(str.equals("hello")){
System.out.println(str);
}
System.out.println("End");
scanner.close();
}
}
package struct;
import java.util.Scanner;
//if双分支结构
public class IfDemon02 {
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("不及格");
}
}
}
package struct;
import java.util.Scanner;
//if...else多分支结构
public class IfDemon03 {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
System.out.println("请输入你的成绩");
int score=scanner.nextInt();
if(score==100){
System.out.println("满分");
}else if(score<100&&score>90)
{
System.out.println("A");
}else if(score<90&&score>80)
{
System.out.println("B");
}else if(score<80&&score>60)
{
System.out.println("C");
}else if(score<60&&score>0)
{
System.out.println("不及格");
}
else{
System.out.println("您输入有误");
}
scanner.close();
}
}