2021.03.22笔记
Main
package edu.xcdq;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int jia = 0;
for ( int i = 1; i<=10 ;i++){
jia = jia +i ;
if (jia > 20){
System.out.println(“得到大于20的当前数” + i);
break;
}
}
System.out.println(jia);
}
}
demo01
import java.util.Scanner;
/**
*@qvthor liuwenzheng
*@date 2021/3/22 8:25
*/public class demo01 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println(“请输入班级总人数”);
int num = scanner.nextInt();
int count = 0 ;
for (int i = 1 ; i <= num ; i++ ){
System.out.println(“请输入第” + i + “位学生的成绩”);
int score = scanner.nextInt();
if (score <80){
continue; //跳过当前循环,本轮循环后面的代码不在执行
}
count++;
}
System.out.println("80分以上的人数为" + count);
}
}
demo02
package edu.xcdq;
/**
@qvthor liuwenzheng
@date 2021/3/22 9:06
*/
public class demo02 {
public static void main(String[] args) {
int sum = 0 ;
for (int i = 2 ; i<= 10; i++){
System.out.println(“当前的i=” + i +“sum”+sum );
}
System.out.println(sum);
for (int i = 1; i<=10 ;i++ ){
if (i % 2 ==0){
sum += i;
}
}
System.out.println(sum);
}
}
demo03
package edu.xcdq;
import java.util.Scanner;
/**
@qvthor liuwenzheng
@date 2021/3/22 9:18
/
public class demo03 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in); //三引号原格式不变
System.out.println(“欢迎进入迷你游戏平台”);
System.out.println(“请选择你喜欢的游戏”);
System.out.println(“");
System.out.println("\t\t\t1.斗地主");
System.out.println("\t\t\t2.斗牛");
System.out.println("\t\t\t3.泡泡龙");
System.out.println("\t\t\t4.连连看");
System.out.println("*******”);
System.out.println(“请选择,输入数字:”);
int youxi1 = scanner.nextInt();
switch (youxi1){
case 1:
System.out.println(“欢迎进入斗地主房间”);
break;
case 2:
System.out.println(“欢迎进入斗牛房间”);
break;
case 3:
System.out.println(“欢迎进入泡泡龙房间”);
break;
case 4:
System.out.println(“欢迎进入连连看房间”);
break;
}
}
}
demo04
package edu.xcdq;
import java.util.Scanner;
/**
@qvthor liuwenzheng
@date 2021/3/22 9:26
*/
public class demo04 { //继上demo03
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println(“迷你游戏平台>游戏晋级”);
int count = 0 ;
for (int i = 0; i < 5; i++) {
System.out.println(“你正在玩第” + (i + 1) + “局游戏,成绩为”);
int score = scanner.nextInt();
if (score >=80){
count ++;
}
System.out.println(“继续玩下一句吗?(yes/no)”);
String shifou = “”;
if (i<4){
System.out.println(“继续下一句吗?(yes/no)”);
shifou = scanner.next();
}
if (“no”.equals(shifou)) { //为了避免出现用户为空,导致程序崩溃,建议把确定的“no”写在前面
System.out.println(“不足5局,不能晋级”);
break;
}
if (i<4){ //已经是第4局,也就是最后一局,下局不在提示
System.out.println(“进入下一句”);
}
}
System.out.println(“游戏结束”);
int youxi2 = count/5 ;
if (youxi2 >= 0.8) {
System.out.println(“恭喜,通过1级”);
}else if(youxi2>=0.6) {
System.out.println(“恭喜,通过2级”);
}else {
System.out.println(“还需要加油哦”);
}
}
}