繁体   English   中英

制作数组并验证条目

[英]Making an array and validaing an entry

因此,在我们班上,我们需要建立学校注册系统。 命名学生ID号等。现在,我需要根据变量的限制来验证输入。 例如,学生的R分数必须为数字。 考虑我使用阵列的最佳方式是什么?

   while (finetudiant==false)
        {
        System.out.println("Quel est son prénom?");
        prenom[i]= clavier.nextLine();

        System.out.println("Quel est sa nationalité?");
        nationalite[i]= clavier.nextLine();

        System.out.println("Quel est son code permanent?");
        codeperm[i]= clavier.nextLine();

        System.out.println("Quel est son no. d'étudiant?");
        noetudiant[i]= clavier.nextLine();

        System.out.println("Quel est son nombre d'années de scolarité?");
        scolarite[i]= Integer.decode(clavier.nextLine());

        System.out.println("Quel est sa cote R?");
        coter[i]= Integer.decode(clavier.nextLine());

        System.out.println("Désirez vous ajouter un autre étudiant?");
        System.out.println("Oui=1 Non=2");
        n1= Integer.decode(clavier.nextLine());

        i++;

        if (n1==2)
          {
           finetudiant=true;

          }

        }

因此,为了精确起见,前四个字符串是字符串,因此不会使我的程序崩溃,但是如果输入的值不是数字本身,后两个将用于输入。 人们通常会使用什么方式?

PS:这是我在这里的第一篇文章,我是一个月前开始编程的,所以请谅解。 哦,我是法国人,请原谅我的代码和错别字...

PS:键盘指的是键盘,它是我的系统。

谢谢!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM