My code:

printf("\n"); 
  printf("\tSlalom Race, Version 1.0\t\t\n\n");
  printf("1. Play\n");
  printf("2. Instructions\n"); 
  printf("3. Quit\n\n"); 
  printf("Your choice: "); 
  scanf("%d", &choice); 
  }  
 
  /* Initializes loop to begin game */ 
  while (choice != 3) { 
 
  /* Begins execution of game and Selects instructions if needed */ 
  while (choice == 1) { 
  printf("You are at the start.\n"); 
   printf("Time elapsed: 0.000000 sec\n"); 
  printf("Current velocity: 0.000000 m/sec\n"); 
  printf("Next Gate: 1. Velocity limit: 10.00 m/sec\n"); 
   printf("Your action (1 - 7):"); 
   scanf("%d", &accelComand); 
 

   /* Determines if the command is in between 1 and 7 */ 
   while (!(accelComand <=SEVEN) || !(accelComand >= 1)) { 
   printf("Your action (1 - 7):"); 
   scanf("%d", &accelComand); 
   } 
 
    /* Calculates velocity and time of Leg1 */ 
   accelLeg1 = acceleration[accelComand-1]; 
   velLeg1 = sqrt(TWO*accelLeg1*FIFTY); 
   timeLeg1 = (velLeg1 / accelLeg1); 
   printf("\n\n"); 
 
   if (velLeg1 > 10) { 
   printf("\n\n\n");
    printf("Your velocity at gate 1 was %f m/sec\n",velLeg1); 
   printf("You have lost control and went into"); 
   printf(" a nearby snow pile!\n");
    printf("You failed the race and went"); 
   printf(" face down into the snow!\n"); 
   printf("Better luck next time!\n"); 
 
    } 
 else { 
  if (velLeg1 <= 0) {
   printf("You stopped before reaching the gate.\n"); 
  printf("Your attempt to pick up the speed laned you"); 
  printf(" in a snow pile.\n"); 
  printf("You failed the race due to your"); 
  printf("overburdening caution.\n"); 
  printf("Better luck next time.\n");
  }
   } 
  printf("\n"); 
  printf("You are at Gate 1\n"); 
  printf("Time elapsed: %f sec\n", timeLeg1);
   printf("Current velocity: %f m/sec\n",velLeg1); 
   p rintf("Next Gate: 2. Velocity limit: 18.00 m/sec\n"); 
    printf("Your action (1 - 7):"); 60. scanf("%d", &accelComand);

As you can see my code asks the user to input 3 numbers: 1,2,3 in lines 1-7. My only concern is when they choose 1. When they select "1", game execution begins and depending on the given command (the command itself is the acceleration which determines the time and velocity) lines 34 - 51 will determine the output of lines 54-60. If one of the conditions are satisfied in lines 34-51 THEN the program will go back in asking the user in lines 1-7 again. That is my problem, i dont know what to put in lines 34-51 if one of the conditions are satisfied and go back in asking the user in lines 1-7. Any suggestions?????

Edited 7 Years Ago by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

i really want to help you, but your code is painful to look at. please repost it and enclose your code within [code] [/code] tags.

always use good coding practice like proper indention of code blocks, and do not put line numbers in front of each line, it only serves to make it less readable.

Edited 7 Years Ago by jephthah: n/a

This article has been dead for over six months. Start a new discussion instead.