package niu.cheng2;
import java.util.Scanner;
public class qqDemo {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
for(int x=2;x>=0;x--){
String zhang1="1006215179";
String mi1="ncf1006215179";
System.out.println("请你输入账号:");
String zhang=sc.nextLine();
System.out.println("请你输入密码:");
String mi=sc.nextLine();
if(zhang.equals(zhang1)){
if(mi.equals(mi1)){
System.out.println("恭喜您,成功登陆!");
System.out.println("聊天");
break;
}else{
System.out.println("你输入的账号或密码有误,请重新输入");
System.out.println("你还有"+x+"次机会");
}
}else{
System.out.println("你输入的账号或密码有误,请重新输入");
System.out.println("你还有"+x+"次机会");
}
if(x==0){
System.out.println("请明天重试吧");
}
}
}
import java.util.Scanner;
public class qqDemo {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
for(int x=2;x>=0;x--){
String zhang1="1006215179";
String mi1="ncf1006215179";
System.out.println("请你输入账号:");
String zhang=sc.nextLine();
System.out.println("请你输入密码:");
String mi=sc.nextLine();
if(zhang.equals(zhang1)){
if(mi.equals(mi1)){
System.out.println("恭喜您,成功登陆!");
System.out.println("聊天");
break;
}else{
System.out.println("你输入的账号或密码有误,请重新输入");
System.out.println("你还有"+x+"次机会");
}
}else{
System.out.println("你输入的账号或密码有误,请重新输入");
System.out.println("你还有"+x+"次机会");
}
if(x==0){
System.out.println("请明天重试吧");
}
}
}
}
package niu.cheng2;
import java.util.Scanner;
public class CaiGame{
private CaiGame(){}
public static void start(){
int number=(int)(Math.random()*100)+1;
while(true){
Scanner sc=new Scanner(System.in);
System.out.println("请你输入一个数字;");
int x=sc.nextInt();
if(x>number){
System.out.println("你输入的数字"+x+"大了");
}else if(x<number){
System.out.println("你输入的数字"+x+"小了");
}else{
System.out.println("恭喜你,猜对了");
break;
}
}
}
}