Use while loop to sum 100 ramdom numbers : While : Statement Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Statement » While »

 

Use while loop to sum 100 ramdom numbers


 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var sum:Number = 0;
        while (sum < 100) {
           trace(sum + " - not there yet.");
           var random:Number = Math.ceil(Math.random() 10);
           sum += random;
        }
        trace(sum + " - surpassed 100. END");
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Statement
» While