first commit
This commit is contained in:
commit
02735c657d
11
Java2024.iml
Normal file
11
Java2024.iml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
10
src/Example07.java
Normal file
10
src/Example07.java
Normal file
@ -0,0 +1,10 @@
|
||||
public class Example07 {
|
||||
public static void main(String[] args) {
|
||||
int x = 5;
|
||||
if (x < 10) {
|
||||
x ++; // x = x + 1;
|
||||
}
|
||||
|
||||
System.out.println("x=" + x);
|
||||
}
|
||||
}
|
11
src/Example08.java
Normal file
11
src/Example08.java
Normal file
@ -0,0 +1,11 @@
|
||||
public class Example08 {
|
||||
public static void main(String[] args) {
|
||||
int num = 20;
|
||||
|
||||
if (num % 2 == 0) {
|
||||
System.out.println("num是一个偶数");
|
||||
} else {
|
||||
System.out.println("num是一个奇数");
|
||||
}
|
||||
}
|
||||
}
|
14
src/Example09.java
Normal file
14
src/Example09.java
Normal file
@ -0,0 +1,14 @@
|
||||
public class Example09 {
|
||||
public static void main(String[] args) {
|
||||
int grade = 75;
|
||||
if (grade > 80) {
|
||||
System.out.println("该成绩的等级为优");
|
||||
} else if (grade > 70) {
|
||||
System.out.println("该成绩的等级是良");
|
||||
} else if (grade > 60) {
|
||||
System.out.println("该成绩的等级是中");
|
||||
} else {
|
||||
System.out.println("该成绩的等级是差");
|
||||
}
|
||||
}
|
||||
}
|
11
src/Example10.java
Normal file
11
src/Example10.java
Normal file
@ -0,0 +1,11 @@
|
||||
public class Example10 {
|
||||
public static void main(String[] args) {
|
||||
int x = 0;
|
||||
int y = 10;
|
||||
int max;
|
||||
|
||||
max = x > y ? 100 : 1000;
|
||||
|
||||
System.out.println("max=" + max);
|
||||
}
|
||||
}
|
31
src/Example11.java
Normal file
31
src/Example11.java
Normal file
@ -0,0 +1,31 @@
|
||||
public class Example11 {
|
||||
public static void main(String[] args) {
|
||||
int week = 1;
|
||||
|
||||
switch (week) {
|
||||
case 1:
|
||||
System.out.println("星期一");
|
||||
break;
|
||||
case 2:
|
||||
System.out.println("星期二");
|
||||
break;
|
||||
case 3:
|
||||
System.out.println("星期三");
|
||||
break;
|
||||
case 4:
|
||||
System.out.println("星期四");
|
||||
break;
|
||||
case 5:
|
||||
System.out.println("星期五");
|
||||
break;
|
||||
case 6:
|
||||
System.out.println("星期六");
|
||||
break;
|
||||
case 7:
|
||||
System.out.println("星期日");
|
||||
break;
|
||||
default:
|
||||
System.out.println("数值错误");
|
||||
}
|
||||
}
|
||||
}
|
9
src/Example12.java
Normal file
9
src/Example12.java
Normal file
@ -0,0 +1,9 @@
|
||||
public class Example12 {
|
||||
public static void main(String[] args) {
|
||||
int x = 5; // 定义变量x,初始值为1
|
||||
while (x <= 4) { // // 循环条件
|
||||
System.out.println("x = " + x); // 条件成立,打印x的值
|
||||
x ++; // x进行自增
|
||||
}
|
||||
}
|
||||
}
|
9
src/Example13.java
Normal file
9
src/Example13.java
Normal file
@ -0,0 +1,9 @@
|
||||
public class Example13 {
|
||||
public static void main(String[] args) {
|
||||
int x = 5;
|
||||
do {
|
||||
System.out.println("x = " + x);
|
||||
x ++;
|
||||
} while (x <= 4);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user