JAVA:使用for循环结构,用来统计调查的客户人数,直到循环录入10位客户的年龄后结束

来源:百度知道 编辑:UC知道 时间:2024/05/17 00:10:08

import java.util.Scanner;

public class Test {

public void count() {
for (int i = 1; i < 11; i++) {
System.out.println("The " + i + " come");
Scanner scan = new Scanner(System.in);
int age = scan.nextInt();
System.out.println("The " + i + " people age is " + age);
System.out.println("-----------------------");
}
}
public static void main(String[] args) {
Test test = new Test();
test.count();
}
}

public static void main(String[] args) throws IOException{
int count = 0;
for(int i=0;i<所有客户数;i++){

if(count <11){
if(x符合条件){
// 数据库操作
count ++ ;
}
}
}