<mosaic.cnfolio.com>
PROGRAM
  1. /* START
  2. get the values of how many pokemon and pokemon candy the player owns and if wanted how many candy it requires to evolve the pokemon (if another pokemon is being used other than a 12 candy evolution pokemon)
  3.  
  4. IF the amount of pokemon and/or pokemon candy and/or the pokemon candy amount required to evolve is less than zero
  5.    THEN display an error message to say that positive values need to be used
  6.  
  7.       ELSE
  8.          IF the values of the amount of pokemon and/or pokemon candy and/or the required candy to evolve are not integers
  9.             THEN display a message of needing to put in an integer value and what format to use for the input     
  10.    
  11.                ELSE
  12.                   IF the candy amount is less than the required amount of candy to evolve the pokemon
  13.                      THEN display an error message of needing at least the right amount of candy to do an evolution and what format to use for the input      
  14.                  
  15.                         ELSE
  16.                      WHILE the pokemon amount is greater than zero and the pokemon candy amount is greater than or equal to the amount of candy required to evolve 
  17.                            minus one from the pokemon amount
  18.                            minus the required amount of candy to evolve plus one from the pokemon candy amount
  19.                            add one to the amount of evolutions you can do
  20.                            END WHILE
  21.                   END IF
  22.          END IF
  23. END IF
  24.                      display a message to the user to say the total xp with a lucky egg, without a lucky egg, how long it takes to evolve them and how many lucky eggs it would use up
  25.  
  26. END */
  27.    
  28.  
  29.  
  30.  
  31.  
  32. #include <stdio.h>
  33. #include <math.h>
  34.  
  35. int main( void )
  36. {
  37.  
  38. /* Variable Setting. */
  39. float pokemonAmount, candyAmount, evolutions = 0, candyRequired = 12;
  40. int xp = 500;
  41.  
  42. scanf("%f %f %f", &pokemonAmount, &candyAmount, &candyRequired); /* Setting values for the variables from a user input */
  43.  
  44.  
  45. /* Error checking. Negative, integer, letter or symbol. */
  46. if(pokemonAmount<0 || candyAmount<0 || candyRequired<0) /* If the pokemonAmount, candyAmount or candyRequired is less than zero then print an error message of needing positive values */
  47.    {
  48.     printf("Please input positive integer values, thank you. \nPlease put it into format 'pokemon-amount candy-amount candy-to-evolve-amount' wihout the quotation marks, candy-to-evolve-amount is not required and is default set to 12.");
  49.    }
  50. else if(fmod((pokemonAmount * 10), 10) != 0 || fmod((candyAmount * 10), 10) != 0 || fmod((candyRequired * 10), 10) != 0) /* If the remainder of the pokemonAmount, candyAmount or candyRequired multiplied by 10 and then divided by 10 is not equal to zero then a non integer value has been put in so an error message will be printed of needing to put in an integer */
  51.    {    
  52.     printf("Please put in an integer, thank you. \nPlease put it into format 'pokemon-amount candy-amount candy-to-evolve-amount' wihout the quotation marks, candy-to-evolve-amount is not required and is default set to 12. \n");      
  53.    }
  54. else if(candyAmount < candyRequired) /* If the candyAmount is less than the candyRequired then there is not enough candy to do one evolution so print an error message of needing enough candy */
  55.    {    
  56.    printf("You need at least %.0f candy to do 1 evolution.", candyRequired);     
  57.    }
  58. else
  59.    {
  60. /* While loop to add 1 to evolutions each cycle */
  61.    while(pokemonAmount > 0 && candyAmount > candyRequired) /* As long as the pokemonAmount is greater than 0 and the candyAmount is greater than the candyRequired the while loop will run, it will exit the loop when it can't do any more evolutions */
  62.       {
  63.       pokemonAmount --; /* The while loop takes away the resources used to do an evolution and then adds 1 to how many evolutions it can do, when it can't do any more evolutions the while loop will not run and the variable 'evolutions' is now at the value of how many evolutions can be done */
  64.       candyAmount = candyAmount - candyRequired + 1;
  65.       evolutions++;
  66.       }
  67.       printf("The total xp gained will be: \n %.0f with a lucky egg. \n %.0f without a lucky egg. \nThis takes a total time of %.0f seconds. \nThis uses up %.0f lucky eggs.", evolutions * 1000, evolutions * 500, evolutions * 30, ceil((evolutions * 1000) / 60000) );     
  68.    }
  69. }