import java.util.Scanner;
public class Simpletest{
public static void main(String args[]){
System.out.println("Enter a digit! ");
Scanner input = new Scanner(System.in);
//输入数字
int ok=input.nextInt();
if (ok < 9)
System.out.println("Your answer is smaller than 9!");
else if (ok == 9)
System.out.println("Your answer is equal than 9!");
else
System.out.println("Your answer is bigger than 9!");
}
}
if (x<=9)
{
System.out.println("Enter a digit! ");
Scanner input = new Scanner(System.in);
int ok=input.nextInt();
System.out.println("Your answer is smaller than 9!");
}
加下面3行代码就行的 典型的if else语句的
else{
System.out.println("Your answer is bigger than 9!")
}
希望对你有所帮助
import java.util.Scanner;
public class Simpletest{
public static void main(String args[]){
int x=9;
if (x<=9)
{
System.out.println("Enter a digit! ");
Scanner input = new Scanner(System.in);
int ok=input.nextInt();
System.out.println("Your answer is smaller than 9!");
}else{
System.out.println("Enter a digit! ");
Scanner input = new Scanner(System.in);
int ok=input.nextInt();
System.out.println("Your answer is bigger than 9!");
}