题目要求:
从键盘接收用户输入的两个字符串,第一个代表用户名,第二个代表密码。
(1)如果用户名是SwpuIot,并且密码是123456,则输出:Welcome
(2)如果用户名正确,密码不正确,输出:Mismatch
(3)其他情况下,输出:NotExist
要输出的信息,建议从题目中复制,确保精确匹配。
输入格式:
用空格分隔开的两个字符串。
输出格式:
首字母大写的一个单词或词组。
输入样例:
SwpuIot 123456
输出样例:
Welcome
代码块:
import java.util.Scanner;
public class LoginInformation {
public static void main(String[] args) {
String str = "SwpuIot 123456";
String[] strs = str.split(" ");
Scanner sc = new Scanner(System.in);
String s1 = sc.next();
String s2 = sc.next();
sc.close();
if(strs[0].equals(s1) && strs[1].equals(s2)) {
System.out.println("Welcome");
}else if(strs[0].equals(s1) && !strs[1].equals(s2)) {
System.out.println("Mismatch");
}else {
System.out.println("NotExist");
}
}
}