vendredi 30 juin 2017

how can i increment an if statement inside a while loop.

I'm trying to increment the count in each of the if statements. but it is not reading the count. if i don't use break it is going forever. i need to keep count because out of this loop i need to print bankruptcy if the count is less than 10.

      while(count<=10 ){
      boolean flag = false;
      String status="";
     while (true){
      if (diff>=10 &&array[rows][0]== min ){
         count++;
         status= "rising";
         System.out.println("the company stock is "+status+ "the
         price changed by "+ df.format(diff)+ " . total value " +
         df.format(totalvalue)+ "c"+count);

         break;

      }

      if (diff>=10 &&array[rows][0]== max){
          count++;
          status= "falling";
          System.out.println("the company stock is;" +status+ "the
          price changed by "+ df.format(diff)+ " . total value " + 
           df.format(totalvalue)+"c"+count);
         break;

      }
      if (diff<10 ){
       count++;
       System.out.println("the company stock is steady; " +status+ 
       "the price changed by "+df.format(diff)+ " . total value "
        +df.format(totalvalue)+"c"+count);
       flag=true;
       status="steady";


       break;

       }

}

Aucun commentaire:

Enregistrer un commentaire