/*
		     Scheduled Event Discrete Simulation
			   Using Cthread Coroutines

			    Demonstration Program

				 Winter 1994
				 G. Lindstrom

*/

import sim.*;

/*		declaration of application process class
*/

class powers extends process {
 int x;
 int next_time;

 powers(String n, int arg) 
 {
    super(n);
    x = arg;
 }

/**
		definition of application simulation function
*/
  void body()
  { 
    next_time = x;
    for (int i = 1; i<=5; i++)
    { scheduler.hold(next_time-scheduler.clock);
      System.out.println(x + " ^ " + i + " = " + scheduler.clock + ".");
      next_time = scheduler.clock * x;
    }
    terminate();
  }

public static void main(String av[]) {
      scheduler.activate(new powers("2-powers", 2));
      scheduler.activate(new powers("3-powers", 3));
      scheduler.activate(new powers("5-powers", 5));
      // print_ev_list();
      scheduler.run_simulation();
    }
}

