<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3.    read input value for number of pidgey pokemon
  4.    read input value for number of pidgey candies
  5.       
  6.             IF pidgeys is less than 1,
  7.                   
  8.                THEN
  9.                   display an error message saying that the mimimum number of pidgeys has not been met.
  10.       
  11.             END IF
  12.            
  13.             IF candies is less than 12,
  14.                   
  15.                THEN
  16.                   display an error message saying that the mimimum number of candies has not been met.
  17.  
  18.             ELSE
  19.            
  20.             set initial value of XP to 0
  21.             set initial value of evolution to 0
  22.            
  23.                WHILE    the pokecount is greater and 1 and candies is greater than 12
  24.                         subtract 1 from the number of pidgeys
  25.                         subtract 12 from the number of candies
  26.                         add 1 to the number of candies
  27.                         add 500 to the amount of xp gained
  28.                         add 1 to number of evolutions
  29.                END WHILE
  30.                
  31.             END IF
  32.                
  33.                IF number of evolutions is less than 75
  34.                      
  35.                   THEN
  36.                      display the number of evolutions, amount of xp earned with the lucky egg, pidgeys and candies remaining
  37.                        
  38.                   ELSE
  39.                         
  40.                      display the number of evolutions, amount of xp earned with the lucky egg added to the evolutions that dont have the bonus, pidgeys and candies remaining.
  41.                END IF     
  42.       
  43.          
  44. END
  45.  
  46. */
  47.  
  48.  
  49. #include <stdio.h>
  50.  
  51.    int main (void)
  52.    {
  53.    int pokecount;        /* number of pidgey pokemon available for evolution */
  54.    int candies;                        /* number of candies available for pidgey evolution */
  55.    
  56.    
  57.       scanf ( "%d %d", &pokecount, &candies);                     /* read input values */
  58.      
  59.       if (pokecount < 1)                                          /* there must be at least 1 pidgey to evolve*/
  60.             {
  61.                printf ( "ERROR:"
  62.                         "\nNot enough pidgeys. please enter a positive integer.");
  63.                }             
  64.                   
  65.                else
  66.                   if (candies < 12)                                    /* 12 candies are needed per evolution*/
  67.                      {
  68.                         printf ("ERROR:"
  69.                                 "\nNot enough candies. Please enter a positive integer");
  70.                         }
  71.                      
  72.       else
  73.       {
  74.                int xp = 0;               /* xp will be gaining 500 per evolution, so needs an initial value */
  75.                int evolutions =0;                                    /* evolutions will be incrementing, and needs an initial value */
  76.                
  77.                   while ((pokecount > 0) && (candies >= 12))         /* the parameters for while loop, if not met then loop will exit */
  78.                   {
  79.                      pokecount --;                        /* evolving a pidgey removes one from inventory */
  80.                      candies -=12;                        /* each evolution cost 12 pidgey candies */
  81.                      candies ++;             /*  each evolution gives you 1 pidgey candies */
  82.                      xp +=500;                                       /* each evolution gives you 500xp */
  83.                      evolutions ++;            /* each evolution adds 1 to the evolution count */
  84.                    
  85.            }       
  86.            if (evolutions <= 75)
  87.             
  88.             printf ( "Number of evolutions that will take place is %d."
  89.             "\nYou will gain %dxp with a lucky egg"
  90.             "\nYou will have %d remaining pidgeys."
  91.             "\nYou will have %d remaining candies."
  92.             , evolutions, xp*2, pokecount, candies);
  93.          
  94.           else
  95.            
  96.             printf ( "Number of evolutions that will take place is %d."
  97.             "\nYou will gain %dxp with a lucky egg"
  98.             "\nYou will have %d remaining pidgeys."
  99.             "\nYou will have %d remaining candies."
  100.             "\n"
  101.             "\nNote that only the first 75 evolutions will have the lucky egg bonus, as that is the maximum number of evolutions that can take place in the 30 minute timer." /* calculated using 21 seconds for evolution, and 3 seconds for transfer to the professor. 1800s/24s = 75 evolutions*/
  102.             "\nThe remaining evolutions will only earn the normal amount of 500xp per evolution"
  103.             , evolutions, (75*500*2)+(evolutions - 75)*500, pokecount, candies);
  104.        }
  105. }