#include <stdio.h>
#include <stdlib.h>  // needed for rand, srand
#include <unistd.h>  // needed for sleep
#include <time.h>

/* program to pick a number of seconds at random and wait the specified time
 * program illustrates use of a switch statement
 *
 *  Created by David Cowden                  summer 2011
 *  Revised by Dilan Ustek                   5 October 2011
 *  Calls to sleep added by Henry M. Walker  3 February 2015
 */

int main()
{
  /* declare the seconds as an integer */
  int seconds;

  /* generate a random integer and call it seconds */
  srand(time(0));
  seconds = rand()%10 ;

  /*tell me how many up to how many seconds we will count */
  printf("I will count to %d seconds....\n", seconds);

  /* make different cases to tell the program what to print in any case */
  switch (seconds)
    {
    case 1:
      printf("One Mississippi!\n");
      sleep (1);
      break;
    case 2:
      printf("One Mississippi! Two Mississippi!\n");	
      sleep (2);
      break;
    case 3:
      printf("One Mississippi! Two Mississippi! Three Mississippi!\n");
      sleep (3);
      break;
    case 4:
      printf("One Mississippi! Two Mississippi! Three Mississippi! Four Mississippi!\n");
      break;
      sleep (4);
    case 5:
      printf("One Mississippi! Two Mississippi! Three Mississippi! Four Mississippi! Five Mississippi!\n");
      sleep (5);
      break;
    default:
      printf("Oh Susanna, oh don't you cry for me. I come from Alabama with a banjo on my knee!\n");
      sleep (seconds);
      break;
    }

  printf ("done\n");
  return 0;
}
