import java.util.Scanner;
public class Class2 {
public static void main(String[] args) {
int age;
String password = "big.110@go";
String username = "big";
Scanner keyboardInput = new Scanner(System.in);
System.out.print("Please enter your Usename: ");
username = keyboardInput.next();
System.out.print("Please enter your age: ");
age = keyboardInput.nextInt();
System.out.print("Please enter your password: ");
password = keyboardInput.next();
if(keyboardInput.next().equals(username)
&& keyboardInput.nextInt() >= 18
&& keyboardInput.equals(password)) {
System.out.print("Welcome");
} else {
System.out.print("Something is wrong!\n Try again");
}
}
}
答案 0 :(得分:0)
你在代码中犯了很多错误。
import java.util.Scanner;
public class Class2 {
public static void main(String args[]) {
int age;
String password1 = "big.110@go";
String username1 = "big";
Scanner keyboardInput = new Scanner(System.in);
System.out.print("Please enter your Usename: ");
String username = keyboardInput.nextLine();
System.out.print("Please enter your password: ");
String password = keyboardInput.nextLine();
System.out.print("Please enter your age: ");
age = keyboardInput.nextInt();
if(username.equals(username1)
&& password.equals(password1)
&& age>=18 ) {
System.out.print("Welcome");
} else {
System.out.print("Something is wrong!\n Try again");
}
}
}