-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathApp.java
More file actions
173 lines (102 loc) · 2.51 KB
/
App.java
File metadata and controls
173 lines (102 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
public class App {
public static void main(String[] args) {
java.util.Scanner input = new java.util.Scanner(System.in);
int errorCount = 0; //错误次数
String lastErrorName = ""; //最后一次错误的账号
//如果输入用户名和密码连续错误3次,提示”账号冻结
while(errorCount < 3) {
System.out.println("请输入账号:");
String userName = input.next();
System.out.println("请输入密码:");
String password = input.next();
if("tom".equals(userName) && "123123".equals(password)) {
System.out.println("登录成功");
errorCount = 3;
} else {
if(!userName.equals(lastErrorName)) {
errorCount = 0;
lastErrorName = userName;
}
errorCount++;
if(errorCount == 3) {
System.out.println("账号被冻结");
}
}
}
/*
int i = 0;
while(i < 10) {
System.out.println(i);
i++;
}*/
/*
for(int i = 0;i < 10;i++) {
System.out.println(i);
}
*/
/*
java.util.Scanner input = new java.util.Scanner(System.in);
String name;
do {
System.out.println("请输入姓名:");
name = input.next();
if(!"quit".equals(name)) {
System.out.println("您的姓名是:" + name);
}
}while(!"quit".equals(name));
*/
/*
//先执行,再判断
int count = 10;
do{
System.out.println("hello," + count);
count--;
}while(count > 0);
*/
/*
//1. 获取班级总人数
java.util.Scanner input = new java.util.Scanner(System.in);
System.out.println("请输入班级总人数:");
int count = input.nextInt(); //总人数
//2. 输入每个同学的成绩,将成绩累加获得总成绩
int total = 0; //总成绩
int c = 0;
int i = 1;
while(i <= count) {
System.out.println("请输入第" + i +"个同学的成绩:");
int score = input.nextInt();
if(score >= 80) {
c++;
total += score;//total = total + score;
}
i++;
}
//3. 使用总成绩除以班级总人数,获取平均成绩
int avg = total / c;
//4. 输出平均成绩
System.out.println("总成绩为:" + total + " 平均成绩为:" + avg);
*/
/*
int count = 10;
while(count > 20) {
System.out.println("xxx");
count++;
}
*/
//.....
/*
int count = 1;
while(count <= 100) {
System.out.println(count + "只青蛙" + count + "张嘴," + (count * 2) +"只眼睛" + (count * 4) +"条腿");
count++;
}
*/
/*
int count = 0; //初始化
while(count < 3) { //条件判断部分
System.out.println("Hello");
count++; //更改变量
}
*/
}
}