2

私は Java プログラミングを学んでいますが、このコードに問題があります。私の問題は、2 番目の while ループを停止できないことです ( while (done ==1){ .. })

done = 2 を実行すると、プログラムが再開されます...

int stopme3 = 1;
while (stopme3 == 1) {        
    /* Appel de la méthode Afficher les propriétaires */
    AfficherProprio();
    int choix_proprio = ChoisirProprio();

    /* Appel de la méthode Afficher les Comptes du Propriétaire */
    AfficherComptesProprietaire(choix_proprio);

    /* Choix du compte à modifier */
    System.out.println("N° de compte:");
    int choixCompte = lectureClavier.nextInt();
    /* Test si comptes existants du proprio */
    if (choixCompte == tab_compte[choix_proprio]._num_compte) {
        int done = 1;
        while (done == 1) {
            /* Création d'une ligne comptable */
            tab_compte[choix_proprio].CreerLigneC();
            System.out.println("Ajouter une ligne comptable supplémentaire ?");
            System.out.println("1 - Oui");
            System.out.println("2 - Non");
            done = lectureClavier.nextInt();
        }
    } else {
        System.out.println("Compte sélectionné inexistant.");
    }
}

助けていただければ幸いです。どうもありがとうございました。

4

1 に答える 1

3
int stopme3 = 1;
            while (stopme3 == 1) { // This loop will keep running till condition is true


int done = 1;
    while (done == 1) {// This loop will keep running till condition is true

したがって、これは無限に実行されます。したがって、このようにしたいかもしれません

  int stopme3 = 1;
  while (stopme3 == 1) { 

   if(some condition is met){
           stopme3  =2;
       }

}
于 2013-11-01T10:08:11.110 に答える