JAVA的流程控制
2021-03-19 03:25
标签:流程 obj lin efault static manage output def lse JAVA的流程控制 标签:流程 obj lin efault static manage output def lse 原文地址:https://www.cnblogs.com/langtaoshuo/p/13951606.html1.流程控制:顺序结构,分支(判断)结构,循环结构。
package com.langtao.scanner;
import com.sun.deploy.security.SelectableSecurityManager;
import java.sql.SQLOutput;
import java.util.Scanner;
public class Demo2 {
public static void main(String[] args) {
//New an object of Scanner to receive the input from Keyboard from the user.
Scanner scanner = new Scanner(System.in);
//String str = scanner.nextLine();
//System.out.println(str);
int m = 3;
while(m>0){
System.out.println("Please enter your score: ");
if(scanner.hasNextInt()){
int score = scanner.nextInt();
System.out.println("Your score is: " + score);
switch (score/10){
case 10:
System.out.println("Excellent, full mark!");
break;
case 9:
System.out.println("Very good!");
break;
case 8:
case 7:
System.out.println("Not bad.");
break;
case 6:
System.out.println("Pass!");
break;
default:
System.out.println("Failed");
}
}else{
System.out.println("Invalid entry, please enter your score.");
}
m--;
}
scanner.close();
}
}
上一篇:java温习---对象
下一篇:如何使用线程池?